Method, device and equipment for text typesetting rendering, medium and product
By providing text layout rendering interfaces defined by operating systems and text layout components, the problems of high development costs and inconsistent display effects under different operating systems are solved, and efficient text layout rendering is achieved.
Patent Information
- Application Number
- CN202511014021.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-22
- Publication Date
- 2025-11-07
AI Technical Summary
Different operating systems have different text layout and rendering capabilities, which means that developers need to code multiple times for different platforms, increasing development and maintenance costs, and making it difficult to ensure the consistency of rich text display.
Two text layout rendering interfaces are provided. The first interface is based on the operating system type definition, and the second interface is based on the text layout component definition. By selecting the interface, the font abstraction module, font management module, and text measurement module are determined, and text measurement results are generated for text layout rendering.
This avoids the need for developers to write adaptation code for different operating systems, improves text layout and rendering efficiency, and ensures consistent display effects across different operating systems.
Smart Images

Figure CN120911401A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of computers, and more specifically, to a method, an apparatus, a computing device, a computer storage medium, and a computer program product for text layout rendering. BACKGROUND
[0002] Rich text is a form of text that goes beyond the basic format of plain text. It not only contains textual content but also various formats, styles, and embedded multimedia elements, making the content presentation richer and more expressive. Compared with plain text, rich text can support adjustments to the font, size, color, and thickness of characters, and can also embed images, tables, hyperlinks, and other objects. SUMMARY
[0003] In a first aspect of embodiments of the present disclosure, a method for text layout rendering is provided. The method comprises: receiving a selection of one of a first text layout rendering interface and a second text layout rendering interface, the first text layout rendering interface being defined based on a type of an operating system, and the second text layout rendering interface being defined based on a text layout component; determining, based on the selection, a font abstraction module, a font management module, and a text measurement module, wherein the font abstraction module is configured to establish a mapping between a font and a glyph, and wherein the font management module is configured to find a font capable of displaying the glyph; and measuring, based on the text measurement module, a rich text to generate a text measurement result for the text layout rendering.
[0004] In a second aspect of embodiments of the present disclosure, an apparatus for text layout rendering is provided. The apparatus comprises: a receiving unit configured to receive a selection of one of a first text layout rendering interface and a second text layout rendering interface, the first text layout rendering interface being defined based on a type of an operating system, and the second text layout rendering interface being defined based on a text layout component; a determining unit configured to determine, based on the selection, a font abstraction module, a font management module, and a text measurement module, wherein the font abstraction module is configured to establish a mapping between a font and a glyph, and wherein the font management module is configured to find a font capable of displaying the glyph; and a generating unit configured to measure, based on the text measurement module, a rich text to generate a text measurement result for the text layout rendering.
[0005] In a third aspect of embodiments of the present disclosure, an electronic device is provided. The electronic device comprises: at least one processing unit; at least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions, when executed by the at least one processing unit, causing the computing device to perform the method as described in the first aspect of the present disclosure.
[0006] In a fourth aspect of embodiments of the present disclosure, a non-transitory computer storage medium is provided. It includes machine executable instructions that, when executed by a device, cause the device to perform the method as described in the first aspect of the present disclosure.
[0007] In a fifth aspect of embodiments of the present disclosure, a computer program product is provided. It includes machine executable instructions that, when executed by a device, cause the device to perform the method as described in the first aspect of the present disclosure.
[0008] The summary is provided to introduce a selection of concepts, in a simplified form, that are further described below in the DETAILED DESCRIPTION. This summary is not intended to identify key or essential features of the claimed subject matter, nor is it intended to limit the scope of the claimed subject matter. BRIEF DESCRIPTION OF DRAWINGS
[0009] The above and other features, aspects and advantages of various embodiments of the present disclosure will become more apparent from the following detailed description, taken in conjunction with the accompanying drawings, in which like reference numerals denote like elements, and wherein:
[0010] Figure 1 An exemplary flowchart for a text layout rendering process is shown;
[0011] Figure 2 A schematic diagram of a text measurement module is shown, in accordance with some embodiments of the present disclosure;
[0012] Figure 3 A flowchart of a method for text layout rendering is shown, in accordance with some embodiments of the present disclosure;
[0013] Figure 4 A schematic diagram of a process for generating text measurement results based on a first text measurement module is shown, in accordance with some embodiments of the present disclosure;
[0014] Figure 5 A schematic diagram of another process for generating text measurement results based on a first text measurement module is shown, in accordance with some other embodiments of the present disclosure;
[0015] Figure 6 A schematic diagram of a process for generating text measurement results based on a second text measurement module is shown, in accordance with some embodiments of the present disclosure;
[0016] Figure 7 A block diagram of an apparatus for text layout rendering is shown, in accordance with some embodiments of the present disclosure; and Figure 8 A block diagram of a device capable of implementing various embodiments of the present disclosure is shown.
[0017] In all the drawings, same or similar reference numerals denote same or similar elements. DETAILED DESCRIPTION
[0018] It can be understood that all user-related data involved in the technical solution should be obtained and used after the user's authorization. This means that in the technical solution, if the user's personal information needs to be used, the user's explicit consent and authorization are required before obtaining the data, otherwise the relevant data collection and use will not be performed. It should also be understood that in the implementation of the technical solution, relevant laws and regulations should be strictly followed in the collection, use and storage of data, and necessary technical and measures should be taken to protect the user's data security and ensure the safe use of data.
[0019] It can be understood that before using the technical solution disclosed in each embodiment of the disclosure, the type of personal information involved in the disclosure, the use range, the use scenario, etc. should be informed to the user and the authorization of the user should be obtained through appropriate means according to relevant laws and regulations.
[0020] For example, when receiving the user's active request, the user is sent a prompt information to explicitly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can voluntarily choose whether to provide personal information to the electronic device, application program, server or storage medium, etc. software or hardware that performs the operation of the technical solution of the disclosure according to the prompt information.
[0021] As an optional but non-limiting implementation manner, in response to receiving the user's active request, the way of sending the prompt information to the user may be, for example, the pop-up window manner, and the prompt information can be presented in the form of text in the pop-up window. In addition, the pop-up window can also carry selection controls for the user to select "agree" or "disagree" to provide personal information to the electronic device.
[0022] It can be understood that the above notification and user authorization process is only illustrative and does not limit the implementation of the disclosure. Other ways that meet relevant laws and regulations can also be applied to the implementation of the disclosure.
[0023] Embodiments of the disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the disclosure are shown in the drawings, it should be understood that the disclosure can be implemented in various forms, and should not be interpreted as being limited to the embodiments set forth herein, on the contrary, these embodiments are provided to more thoroughly and completely understand the disclosure. It should be understood that the drawings and embodiments of the disclosure are only for exemplary purposes, and are not intended to limit the scope of protection of the disclosure.
[0024] In the description of embodiments of the disclosure, the term "includes" and its similar terms are understood to be open-ended, that is, "including but not limited to". The term "based on" is understood to be "at least partially based on". The term "one embodiment" or "the embodiment" is understood to be "at least one embodiment". The terms "first", "second", and the like can refer to different or the same objects unless explicitly stated otherwise. The following can also include other explicit and implicit definitions.
[0025] Figure 1 An exemplary flowchart for a text layout rendering process 100 is shown. As shown in block 101, a rich text description information is constructed. The rich text description information refers to a set of information that completely records the rich text content and the measurement style by structured data or markup language, where the measurement style represents a set of style attributes used to calculate the glyph geometric size and layout position in the text measurement stage, which can include font size, font, color, glyph thickness, etc. Figure 1
[0026] In the layout process of the rich text, in block 102, text boundary analysis is performed on the rich text, which is used to accurately identify the line break position in the rich text, solve the problem of how to truncate the text at the appropriate position, and make the content after line breaking comply with language rules and reading habits. In block 103, the layout style of the rich text is merged. The layout style merging refers to merging the text segments that are adjacent and have the same style, thereby reducing the layout calculation and drawing call process. In block 104, the text layout information of the rich text is measured. The text layout information measurement refers to calculating the geometric properties (width, height, baseline position, etc.) of each glyph in the text to provide mathematical basis for subsequent line breaking and drawing. It should be understood that the text layout information measurement relies on the text layout capability provided by the operating system. Since different operating systems provide different text layout capabilities, developers need to write adaptive code for different operating systems. In block 105, the rich text is broken into lines based on the line breaking algorithm. In block 106, the line information is post-processed. The line information post-processing means adjusting and optimizing the single line layout after the line breaking is completed. In block 107, the rich text is laid out by lines. The line layout refers to the process of dividing the measured text content by lines and calculating the exact position (horizontal / vertical coordinates) of each character / glyph in each line. In block 108, the page layout result of the rich text is obtained.
[0027] In the drawing process of the rich text, at block 109, a page background is drawn based on the page layout result, and the drawing of the page background refers to drawing the background (such as solid color, gradient, picture, etc.) of the page in the whole text rendering process. However, different operating systems provide different drawing interfaces for text rendering, and developers also need to write adaptive codes for different operating systems. At block 110, a line background is drawn. At block 111, the rich text is drawn based on the drawn page background and line background.
[0028] The inventors have noticed that the method of rich text layout and rendering relies on the text layout and rendering capabilities provided by the operating system. Since the text layout and rendering capabilities provided by different operating systems are different, developers need to write adaptive codes for different operating systems, resulting in the need for developers to code multiple times for different platforms when developing the same function, and the development and maintenance costs are too high. In addition, the same function developed for different operating systems is difficult to guarantee the consistency of the display effect of the rich text, affecting the user experience. Therefore, it is urgent to design a new method for text layout and rendering.
[0029] To this end, the present disclosure provides a method for text layout and rendering. In this method, two text layout and rendering interfaces (for the sake of convenience and explanation, referred to as a first text layout and rendering interface and a second text layout and rendering interface, respectively) are provided, wherein the first text layout and rendering interface is defined based on the type of different operating systems, and the second text layout and rendering interface is defined based on a text layout component. The text layout component is a third-party component responsible for measuring rich text layout information. The selection of one of the first text layout and rendering interface and the second text layout and rendering interface is received. Based on the selection, a font abstraction module, a font management module, and a text measurement module are determined, wherein the font abstraction module is used to establish a mapping between a font and a glyph, and wherein the font management module is used to find a font capable of displaying the glyph. The text measurement module is used to measure the rich text to generate a text measurement result for text layout and rendering.
[0030] It should be understood that the first text layout and rendering interface can be defined according to the type of different operating systems, so the first text layout and rendering interface can have multiple, for example, the first text layout and rendering interface can be defined based on the operating system of the user terminal device, or the first text layout and rendering interface can be defined based on the operating system of the vehicle-mounted device, notebook computer, or any terminal. It should also be understood that for the same device, only the first text layout and rendering interface and the second text layout and rendering interface defined based on the type of the operating system of the device can be selected.
[0031] By the method, the text layout rendering interface can be determined based on the selection of the developer, and a corresponding module is determined based on the type of the text layout rendering interface, and the text layout information is measured based on the corresponding module for text layout rendering, avoiding the developer from writing adaptive codes based on different operating systems and subsequent code maintenance, and improving the efficiency of text layout rendering.
[0032] Figure 2 A schematic diagram of a text measurement module 200 is shown in accordance with some embodiments of the present disclosure. As shown, the module 200 includes a font abstraction module 201, a font management module 202, and a text measurement module 203. The font abstraction module 201 includes a first font abstraction module 204 and a second font abstraction module 205. The font management module 202 includes a first font management module 206 and a second font management module 207. The text measurement module 203 includes a first text measurement module 208 and a second text measurement module 209. Figure 2
[0033] In some embodiments, the font abstraction module 201 can be used to establish a mapping of fonts and glyphs. Specifically, the font abstraction module 201 defines a mapping relationship of Unicode to glyphs and metric information (such as height, baseline position, etc.) of fonts. The font management module 202 can be used to find a font that can display a glyph. The text measurement module 203 can generate a text measurement result based on the obtained text content and measurement style in the rich text, where the text measurement result represents at least one of a plurality of glyphs that make up the rich text, a position of the plurality of glyphs in a page, a size of the plurality of glyphs, and a font of the plurality of glyphs. Illustratively, the text content of the rich text can be, for example, “hello”, and the font is bold. The content “hello” of the rich text and the measurement style (font: bold) can be obtained using the text measurement module 203, the bold font that can be displayed is found from the mapping relationship of the font abstraction module 201 using the font management module 203, and the font metric information of the bold font is obtained using the font abstraction module 201. Based on the obtained bold font and the font metric information, the text measurement result can be generated, for example, at least one of the position coordinates of the two glyphs “hello”, “hello” in the page, the size of “hello”, and the bold font of “hello”.
[0034] In some embodiments, a first text layout rendering interface is defined based on a type of operating system. Based on the first text layout rendering interface, a first font abstraction module 204, a first font management module 206, and a first text measurement module 208 corresponding to the operating system are determined. In some embodiments, a second text layout rendering interface is defined based on a text layout component. Based on the second text layout rendering interface, a second font abstraction module 205, a second font management module 207, and a second text measurement module 209 corresponding to the text layout component are determined.
[0035] Figure 3 A flowchart of a method 300 for text layout rendering according to some embodiments of the present disclosure is shown. The method 300 can be performed, for example, by a device. It should be understood that the device for text layout rendering can be an electronic device with data processing functions, including but not limited to, a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality / virtual reality device, a notebook computer, an ultra-mobile personal computer, a netbook, a personal digital assistant, an Internet of Things device, an industrial terminal, a desktop computer, a server, a computing cluster, a cloud computing center, and various electronic devices with computing functions, and the specific type of the electronic device is not limited in the embodiments of the present disclosure.
[0036] As shown in Figure 3 At block 302, a selection of one of a first text layout rendering interface and a second text layout rendering interface is received, the first text layout rendering interface being defined based on a type of operating system, and the second text layout rendering interface being defined based on a text layout component. In some embodiments, the selection of one of the first text layout rendering interface and the second text layout rendering interface by a developer is received. Illustratively, when the business scenario faced by the developer has strict restrictions on the installation package size of the application, the developer can select the first text layout rendering interface. When the business scenario faced by the developer has a higher requirement on the page size of the rich text, the second text layout rendering interface can be selected.
[0037] At block 304, based on the selection, a font abstraction module, a font management module, and a text measurement module are determined, wherein the font abstraction module is used to establish a mapping of fonts to glyphs, and wherein the font management module is used to look up fonts that can display the glyphs. In some embodiments, based on the selection of the first text layout rendering interface, a first font abstraction module 204 in a font abstraction module 201 is determined to be used, a first font management module 206 in a font management module 202 is determined to be used, and a first text measurement module 208 in a text measurement module 203 is determined to be used. In some embodiments, based on the selection of the second text layout rendering interface, a second font abstraction module 205 in the font abstraction module 201 is determined to be used, a second font management module 207 in the font management module 202 is determined to be used, and a second text measurement module 209 in the text measurement module 203 is determined to be used.
[0038] At block 306, based on the text measurement module, the rich text is measured, and a text measurement result is generated for the text layout rendering. In some embodiments, the rich text is received using the text measurement module 203, font matching is performed for the corresponding content of the rich text using the font management module 202, fonts that can display the corresponding text content of the rich text are determined, and font metric information is extracted from the fonts that can display the corresponding text content of the rich text using the font abstraction module 201. Based on the extracted font metric information, the text measurement result is generated using the text measurement module 203.
[0039] In some embodiments, when the selection of the first text layout rendering interface is received, a first font abstraction module 204, a first font management module 206, and a first text measurement module 208 corresponding to the first text layout rendering interface are determined to be encapsulated. In some embodiments, the first font abstraction module 204 is invoked to establish a mapping of fonts to glyphs, wherein the structure of the first font abstraction module 204 is determined based on the type of the operating system. A plurality of fonts that can be applied to the rich text are looked up using the first font management module 206. Based on the measurement style in the rich text, the first text measurement module 208 is invoked to generate a text measurement result. In some embodiments, when the selection of the second text layout rendering interface is received, a second font abstraction module 205, a second font management module 207, and a second text measurement module 209 corresponding to the second text layout rendering interface are determined. In some embodiments, the second font abstraction module 205 is invoked to establish a mapping of fonts to glyphs, wherein the second font abstraction module 205 is implemented by encapsulating an application programming interface of a text layout component. A plurality of fonts that can be applied to the rich text are looked up using the second font management module 207. Based on the measurement style in the rich text, the second text measurement module 209 is invoked to generate a text measurement result.
[0040] By executing the above method, the module corresponding to the text layout rendering interface can be determined based on the selection of the text layout rendering interface by the developer, and the text layout information is measured based on the corresponding module for text layout rendering, avoiding the developer from writing adaptive code based on different operating systems and subsequent code maintenance, and improving the efficiency of text layout rendering. In addition, based on different development scenarios, the developer can select different interfaces, thereby balancing the package size of the application and the text layout rendering effect.
[0041] Figure 4 A schematic diagram of a process 400 of generating a text measurement result based on a first text measurement module is shown according to some embodiments of the present disclosure. Among them, obtaining rich text description information 401, defining a first text measurement module 402, serialization operation 403, obtaining a text measurement result 407, and putting the text measurement result 407 into a cache 408 are implemented at the C++ language layer. Defining a Java measurement module 404, calling a system-provided application programming interface (API) 405, obtaining a Java measurement result 406 are implemented at the Java language layer.
[0042] As shown in Figure 4 In response to selecting a first text layout rendering interface, it is determined to use the first text measurement module 402 to receive the rich text description information 401, and to perform serialization operation 403 on the text and measurement style in the rich text description information 401. Serialization refers to the process of converting the state of a data structure or object into a format (usually a byte stream) that can be stored or transmitted. Since the operating system corresponding to process 400 (for ease of explanation and description, referred to as the first operating system) is implemented at the Java language layer, and the first text measurement module 402 is implemented at the C++ language layer, the rich text description information 401 needs to be serialized to enable the Java measurement module 404 to process. The Java measurement module 404 obtains the serialized rich text description information, and calls the font abstraction module application programming interface 405 provided by the first operating system to generate the Java measurement result 406. The Java measurement result 406 is serialized to generate the text measurement result 407 and store the text measurement result 407 in the cache 408 so that the first text measurement module 402 can quickly call when encountering repeated text measurement results.
[0043] Figure 5A schematic diagram illustrating another process 500 of generating text measurement result based on the first text measurement module according to some other embodiments of the present disclosure is shown. Among them, obtaining rich text description information 401, defining the first text measurement module 402, defining the core text measurement module 501, calling the system-provided application programming interface 502, obtaining the core text measurement result 503, obtaining the text measurement result 407, and putting the text measurement result 407 into the cache 408 are implemented at the C++ language layer. It should be understood that, unlike the architecture 400, the operating system corresponding to the process 500 (for the sake of convenience of explanation and description, referred to as the second operating system) is implemented at the C++ language layer.
[0044] As shown in Figure 5 response to selecting the first text layout rendering interface, it is determined to use the first text measurement module 402 to receive the rich text description information 401, use the core text measurement module 501 provided by the second operating system to call the system-provided font abstraction module application programming interface 502, and generate the core text measurement result 503. The text measurement result 407 is obtained based on the generated core text measurement result 503, and the obtained text measurement result 407 is stored into the cache 408 so as to facilitate the first text measurement module 402 to quickly call when encountering repeated text measurement results.
[0045] It should be understood that the above description about using the first text measurement module to generate the text measurement result is only an example, and the architecture of the first text measurement module can include more kinds based on the type of the operating system, which is not limited herein. It should also be understood that when the developer selects the first text layout rendering interface, the type of the operating system corresponding to the interface can only be one, that is, the type of the operating system corresponding to the interface is either the first operating system, or the second operating system, or some other type of operating system.
[0046] By performing the above method, when the font abstraction module application programming interface provided by the operating system of the device can be directly called, the corresponding interface is called to generate the text measurement result. When the font abstraction module application programming interface provided by the operating system of the device cannot be directly called by the text measurement module, the font abstraction module application programming interface is encapsulated to call the module to generate the text measurement result, so that more operating systems can be adapted.
[0047] Figure 6A schematic diagram of a process 600 of generating text measurement result based on a second text measurement module is shown according to some embodiments of the present disclosure. Among them, obtaining rich text description information 401, defining a second text measurement module 601, defining a component measurement module 602, calling a third-party text layout component application programming interface 603, calling a third-party font processing library 605, measuring 606 using a font processing library, obtaining a text measurement result 407, and putting the text measurement result 407 into a cache 408 are implemented at the C++ language layer.
[0048] As shown, in response to selecting a second text layout rendering interface, it is determined to use a second text measurement module 601 to receive rich text description information 401. In response to the second text measurement module not having a font processing library 605, a component measurement module 602 is used to call a third-party text layout component 603 related application programming interface to directly generate a text measurement result 407. In response to the second text measurement module encapsulating a font processing library 605, a component measurement module 602 is used to call a third-party text layout component 603 related application programming interface to generate a text measurement result 407. Then, a second font management module (not shown) is used to call a font processing library 605 to back off the generated text measurement result to obtain a text measurement result 407. The obtained text measurement result 407 is stored in a cache 408 so that the first text measurement module 402 can quickly call when encountering repeated text measurement results. Figure 6 It should be understood that back-off means the process of automatically finding an alternative font when a certain character in the text is missing in the current font.
[0049]
[0050] By performing the above method, when the developer selects the second text layout rendering interface, the developer can directly use the third-party text layout component to obtain more diverse font display effects, and also does not require additional coding work.
[0051] In some embodiments, the indention and width of the text's typable area are determined based on the obtained text measurement 407. The text measurement 407 corresponds to the line break position of the content through the boundary analysis of the typable area. The character coordinates are adjusted based on the horizontal alignment manner. The vertical coordinates of the text within the line are adjusted based on the vertical alignment rule. Illustratively, the width of the typable area can be determined based on the indention rule specified by the paragraph style in the rich text, and then the characters exceeding the width limit of the typable area are determined based on the text measurement 407. The line breakable boundary is determined according to the result of the boundary analysis, the characters exceeding the width of the typable area are line broken, and the text within the line is post-processed, for example, including adjusting the horizontal coordinates of the characters based on the horizontal alignment manner and adjusting the vertical coordinates based on the vertical alignment rule within the line. After the text adjustment of the line is completed, the next line is entered, and the above text line breaking and post-processing operations are repeatedly performed to obtain the typesetting result of the content corresponding to the text measurement.
[0052] In some embodiments, the content corresponding to the text measurement is rendered based on the typesetting result of the content corresponding to the text and the selected text typesetting rendering interface. In some embodiments, in response to selecting a first text typesetting rendering interface, the type of the operating system corresponding to the first text typesetting rendering interface is determined. Based on the type of the operating system, the content corresponding to the text measurement is rendered. In response to the type of the operating system corresponding to the first text typesetting rendering interface being unable to parse the rendering instruction, the sequence of the typesetting rendering instruction for the content corresponding to the text measurement is serialized into buffer data. The rendering interface is called by parsing the buffer data to render the content corresponding to the text measurement. In some embodiments, in response to selecting a second text typesetting rendering interface, the rendering interface corresponding to the second text typesetting rendering interface is called to render the content corresponding to the text measurement.
[0053] By performing the above method, the corresponding rendering interface can be determined based on the selected text typesetting rendering interface, and then the content corresponding to the text measurement is rendered. When the corresponding rendering interface cannot be directly called, the rendering instruction can be obtained by serialization, and when the corresponding rendering interface can be directly called, the rendering interface corresponding to the text typesetting rendering interface is directly called to render the content corresponding to the text measurement, thereby improving the universality of the rendering interface in different operating systems.
[0054] The above refers to Figures 1 to 6The described exemplary embodiments provide a method for text layout rendering. Compared with the prior art, the advantages are that a module corresponding to a layout rendering interface can be determined based on a selection of the text layout rendering interface by a developer, and text layout information is measured based on the corresponding module for text layout rendering, thereby avoiding the developer from writing adaptive code based on different operating systems and subsequent code maintenance, and improving the efficiency of text layout rendering. In addition, based on different development scenarios, the developer can select different interfaces, thereby balancing the package size of the application and the text layout rendering effect.
[0055] Figure 7 A block diagram of an apparatus 700 for text layout rendering according to some embodiments of the present disclosure is shown. As shown in FIG. 700, the apparatus 700 includes a receiving unit 702 configured to receive a selection of one of a first text layout rendering interface and a second text layout rendering interface, the first text layout rendering interface being defined based on a type of an operating system, and the second text layout rendering interface being defined based on a text layout component. The apparatus 700 further includes a determining unit 704 configured to determine, based on the selection, a font abstraction module, a font management module, and a text measurement module, wherein the font abstraction module is used to establish a mapping of a font to a glyph, and wherein the font management module is used to look up a font capable of displaying the glyph. The apparatus 700 further includes a generating unit 706 configured to measure, based on the text measurement module, a rich text to generate a text measurement result for text layout rendering.
[0056] In some embodiments, the generating unit 706 can be further configured to: receive, using the text measurement module, the rich text; perform, using the font management module, font matching for content corresponding to the rich text to determine a font capable of displaying the content corresponding to the rich text; extract, using the font abstraction module, font metric information from the font capable of displaying the content corresponding to the rich text; and generate, based on the font metric information, the text measurement result using the text measurement module, wherein the text measurement result indicates at least one of a plurality of glyphs constituting the text, positions of the plurality of glyphs, sizes of the plurality of glyphs, and fonts of the plurality of glyphs.
[0057] In some embodiments, the generating unit 706 can be further configured to: in response to the selection of the first text layout rendering interface, determine a first font abstraction module, a first font management module, and a first text measurement module corresponding to the first text layout rendering interface, the first font abstraction module, the first font management module, and the first text measurement module being encapsulated; call the first font abstraction module to establish a mapping of a font to a glyph, a structure of the first font abstraction module being determined based on the type of the operating system; use the first font management module to look up a plurality of fonts capable of being applied to the rich text; and call the first text measurement module to generate the text measurement result based on a measurement style in the rich text.
[0058] In some embodiments, the generating unit 706 can be further configured to, in response to selecting the second text layout rendering interface, determine a second font abstraction module, a second font management module and a second text measurement module corresponding to the second text layout rendering interface; invoke the encapsulated second font abstraction module to establish a mapping between a font and a glyph, where the second font abstraction module is implemented by encapsulating an application programming interface (API) of the text layout component; find a plurality of fonts applicable to the rich text using the second font management module; and generate the text measurement result using the second text measurement module based on the measurement style in the rich text.
[0059] In some embodiments, the apparatus 700 can be further configured to, in response to the second text measurement module not having a font processing library, generate the text measurement result using the second text measurement module; or in response to the second text measurement module encapsulating the font processing library, invoke the font processing library to fallback the text measurement result using the second font management module.
[0060] In some embodiments, the apparatus 700 can be further configured to generate a layout result of content corresponding to the text measurement result by repeating the following actions: determining an indentation and a width of a layout area based on the text measurement result; determining a line break position of the content corresponding to the text measurement result by boundary analysis; adjusting character coordinates based on a horizontal alignment manner; and adjusting vertical coordinates of in-line text based on a vertical alignment rule.
[0061] In some embodiments, the apparatus 700 can be further configured to render the content corresponding to the text measurement result based on the layout result and the selected text layout rendering interface.
[0062] In some embodiments, the apparatus 700 can be further configured to, in response to selecting the first text layout rendering interface, determine a type of an operating system corresponding to the first text layout rendering interface; and render the content corresponding to the text measurement result based on the type of the operating system.
[0063] In some embodiments, the apparatus 700 can be further configured to, in response to the first text layout rendering interface corresponding to the type of the operating system being unable to parse the rendering instruction, serialize the layout rendering instruction into buffer data; and invoke the rendering interface to render the content corresponding to the text measurement result by parsing the buffer data.
[0064] In some embodiments, the apparatus 700 can be further configured to, in response to selecting the second text layout rendering interface, invoke a rendering interface corresponding to the second text layout rendering interface to render the content corresponding to the text measurement result.
[0065] Figure 8 A block diagram of a device 800 capable of implementing embodiments of the present disclosure is shown. As Figure 8As shown, the device 800 includes a computing unit 801, which can be a central processing unit (CPU) and / or a graphics processing unit (GPU), that can perform various appropriate acts and processes in accordance with computer program instructions stored in a read-only memory (ROM) 802 or computer program instructions loaded into a random access memory (RAM) 803 from a storage unit 808. Various programs and data required by the device 800 for operation can also be stored in the RAM 803. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804. Although not shown in the figure, the device 800 can also include a co-processor. Figure 8
[0066] Various components in the device 800 are connected to the I / O interface 805, including an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0067] The various methods or processes described above can be performed by the computing unit 801. For example, in some embodiments, the methods can be implemented as a computer software program that is tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps or acts of the methods or processes described above can be performed.
[0068] In some embodiments, the methods and processes described above can be implemented as a computer program product. The computer program product can include a computer readable storage medium having computer readable program instructions embodied therewith.
[0069] A computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium can be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
[0070] Computer readable program instructions described herein can be downloaded to respective computing / processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and / or a wireless network. The network can comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and / or edge servers. A network adapter card or network interface in each computing / processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing / processing device.
[0071] Computer readable program instructions for carrying out operations of the present disclosure can be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including object oriented programming languages and conventional procedural programming languages. The computer readable program instructions can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate array (FPGA), or programmable logic array (PLA) can execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present disclosure.
[0072] These computer readable program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks. These computer readable program instructions can also be stored in a computer readable storage medium that can include a non-transitory computer readable storage medium that can direct a computer, a programmable data processing apparatus, and / or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including a
[0073] The computer readable program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0074] The computer program product of the second aspect can include a computer readable storage medium. The computer readable storage medium can include instructions. The instructions can include one or both of: instructions for causing a computer to enable a user equipment device to receive a configuration message from a base station, the configuration message comprising an indication of a set of one or more parameters for a first type of hybrid automatic repeat request process, the first type of hybrid automatic repeat request process being associated with a first type of data; and instructions for causing a computer to enable a user equipment device to receive a configuration message from a base station, the configuration message comprising an indication of a set of one or more parameters for a first type of hybrid automatic repeat request process, the first type of hybrid automatic repeat request process being associated with a first type of data.
[0075] Embodiments of the present disclosure have been described above, with the understanding that these embodiments are exemplary only, and are not restrictive, and are not limited to the disclosed embodiments. Many modifications and changes to the described embodiments are possible, without departing from the scope and spirit of the described embodiments. The selection of terms to be used herein is intended to best explain the principles of the embodiments, practical application, or technical improvement over the technology in the market, or to enable other ordinary skilled persons in the art to understand the embodiments disclosed herein.
Claims
1. A method for text layout rendering, comprising: receiving a selection of one of a first text layout rendering interface and a second text layout rendering interface, the first text layout rendering interface defined based on a type of an operating system, the second text layout rendering interface defined based on a text layout component; based on the selection, determining a font abstraction module, a font management module, and a text measurement module, wherein the font abstraction module is used to establish a mapping of fonts to glyphs, and wherein the font management module is used to look up fonts that can display glyphs; and based on the text measurement module, measuring a rich text to generate a text measurement result for text layout rendering.
2. The method of claim 1, wherein, based on the text measurement module, measuring a rich text comprises: receiving, using the text measurement module, the rich text; performing, using the font management module, font matching for content corresponding to the rich text to determine fonts that can display the content corresponding to the rich text; extracting, using the font abstraction module, font metric information from the fonts that can display the content corresponding to the rich text; and based on the font metric information, generating, using the text measurement module, the text measurement result, wherein the text measurement result indicates at least one of a plurality of glyphs that make up the text, positions of the plurality of glyphs, sizes of the plurality of glyphs, and fonts of the plurality of glyphs.
3. The method of claim 2, wherein, based on the text measurement module, measuring a rich text comprises: in response to selecting the first text layout rendering interface, determining a first font abstraction module, a first font management module, and a first text measurement module that are encapsulated corresponding to the first text layout rendering interface; calling the first font abstraction module to establish a mapping of fonts to glyphs, a structure of the first font abstraction module determined based on the type of the operating system; using the first font management module to look up a plurality of fonts that can be applied to the rich text; and based on measurement styles in the rich text, calling the first text measurement module to generate the text measurement result.
4. The method of claim 2, wherein, based on the text measurement module, measuring a rich text comprises: in response to selecting the second text layout rendering interface, determining a second font abstraction module, a second font management module, and a second text measurement module corresponding to the second text layout rendering interface; calling the encapsulated second font abstraction module to establish a mapping of fonts to glyphs, wherein the second font abstraction module is implemented by encapsulating an application programming interface (API) of the text layout component; using the second font management module to look up a plurality of fonts that can be applied to the rich text; and based on measurement styles in the rich text, using the second text measurement module to generate the text measurement result.
5. The method of claim 4, wherein, using the second text measurement module to generate the text measurement result comprises: in response to the second text measurement module not having a font processing library, using the second text measurement module to generate the text measurement result; or in response to the second text measurement module having the font processing library, using the font processing library to generate the text measurement result. In response to the second text measurement module being packaged with a font processing library, the second font management module is used to call the font processing library to back off the text measurement result.
6. The method of claim 1, wherein, The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes:
7. The method of claim 6, wherein, The method further includes: The method further includes:
8. The method of claim 7, wherein, The method further includes: The method further includes: The method further includes:
9. The method of claim 8, wherein, The method further includes: The method further includes: The method further includes:
10. The method of claim 7, wherein, The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The method further includes: The