Dynamic generation method and device of font chartlet and readable storage medium

文档序号:449830 发布日期:2021-12-28 浏览:2次 中文

阅读说明:本技术 一种字体贴图的动态生成方法、装置、及可读存储介质 (Dynamic generation method and device of font chartlet and readable storage medium ) 是由 张启智 梁东立 王元捷 于 2021-09-26 设计创作,主要内容包括:本发明涉及计算机技术领域,且公开了一种字体贴图的动态生成方法,包括以下步骤:S1、利用操作系统默认绘图工具,根据预设尺寸生成一个固定尺寸空白的初始化位图;S2、利用操作系统默认静态字体工具,生成动态贴图字体基本调控参数;S3、输入目标文本,制作用于动态文本贴图的固定字符集,并统计所有字符集数量MaxTexts;本发明提供的字体贴图的动态生成方法、装置及可读存储介质,提供了一种个性化字体贴图的动态生成方式,制作人员提前完成艺术字体的预先绘制工作,并存放于可读存储介质,在移动网络游戏运行时,应用在交互截面、剧情、活动等各个模块,具有很强的通用性,能显示增强产品体验。(The invention relates to the technical field of computers, and discloses a method for dynamically generating a font chartlet, which comprises the following steps: s1, generating an initialization bitmap with a blank space of a fixed size according to a preset size by using an operating system default drawing tool; s2, generating basic control parameters of the dynamic chartlet font by using an operating system default static font tool; s3, inputting a target text, making a fixed character set for dynamic text mapping, and counting the number MaxTexts of all the character sets; the dynamic generation method, the device and the readable storage medium of the font chartlet provided by the invention provide a dynamic generation mode of the personalized font chartlet, and a producer finishes the pre-drawing work of artistic fonts in advance and stores the artistic fonts in the readable storage medium.)

1. A method for dynamically generating a font chartlet is characterized in that: the method comprises the following steps:

s1, generating an initialization bitmap with a blank space of a fixed size according to a preset size by using an operating system default drawing tool;

s2, generating basic control parameters of the dynamic chartlet font by using an operating system default static font tool;

s3, inputting a target text, making a fixed character set for dynamic text mapping, and counting the number MaxTexts of all the character sets;

s4, drawing all characters by using an operating system default static font tool according to the basic regulation and control parameters, generating a character map file for each character, and generating all character map files which are called character map sets for short;

and S5, arranging the character map files in sequence, and drawing in the initialization bitmap by using an operating system drawing tool.

2. The method for dynamically generating a font map according to claim 1, wherein: the preset size of the initialization bitmap in step S1 may be according to the display memory of the currently mainstream mobile GPU display card, and the preset size is generally 512 × 512 pixels, or may be adjusted to other sizes as needed.

3. The method for dynamically generating a font map according to claim 1, wherein: the basic control parameters in step S2 include: font name, font size.

4. The method for dynamically generating a font map according to claim 1, wherein: the character set in the step S3 is not changeable after the font map is generated.

5. The method for dynamically generating a font map according to claim 1, wherein: the method further includes S6, pre-generating effects such as bold, italic, stroking, shadow, etc. for each character map according to the tool provided by the operating system, where the adding of the effects causes the size of the original character map to change, and at this time, the size of each character map needs to be re-calculated.

6. The method for dynamically generating a font map according to claim 1, wherein: the method further includes S7, in order to save the size of the output bitmap, the arrangement mode of the character pasting set can be optimized, specifically as follows:

s71, sorting the character paste picture set, wherein the strategy of blood discharging can be specified, and the strategies can be selected as follows: the area, width, height, and the most lateral side of each character map;

s72, according to the size of a display memory of a modern mobile hardware GPU display card, predesignating the sizes of 128 multiplied by 128, 256 multiplied by 256, 256 multiplied by 128, 512 multiplied by 512, 1024 multiplied by 1024, 1024 multiplied by 2048, 2048 multiplied by 4096, 4096 multiplied by 4096 and the like as an output bitmap size set;

s73, according to the sequence of the output bitmap size set, sequentially trying whether each size can be filled and placed into all the character paste sets in sequence, at the moment, the character paste sets are already sorted, each time one character paste is placed, dividing the bitmap into a large space and a small space, and iteratively filling all the remaining character paste sets into the two spaces;

and S74, generating a configuration file, and recording the coordinates and size information of all the character strings in the character set corresponding to the map in the output bitmap.

7. A font chartlet dynamic generation device is characterized in that: the system comprises a character set input module, a character set output module and a character set output module, wherein the character set input module is used for generating character sets of languages of Chinese, Japanese, Korean, English and the like; the font chartlet design module is used for setting the regulation and control parameters of the font chartlet, such as the size, the thickening, the italics, the drawing, the shadow and the like according to the font tool of the operating system; and the bitmap generation module is used for outputting a font chartlet with the minimum size and a corresponding configuration file according to the size of the video memory of the modern mobile hardware GPU video card and the character chartlet set based on the input of the specified character set.

8. A computer-readable storage medium characterized by: the medium has stored thereon a computer program which, when executed by a processor, implements a method for dynamic generation of a font map.

Technical Field

The invention relates to the technical field of computers, in particular to a method and a device for dynamically generating a font chartlet and a readable storage medium.

Background

With the continuous development of computer technology, more and more mobile network games improve user experience through interactive interfaces, scenarios, dynamic activities and the like, in the existing mobile network games, text display mainly adopts a static display mode of default of an operating system, only fixed fonts carried by the operating system can be used, and product experience cannot be enhanced during specific use.

Disclosure of Invention

Technical problem to be solved

Aiming at the defects of the prior art, the invention provides a method and a device for dynamically generating a font chartlet and a readable storage medium, which solve the problems in the background art.

(II) technical scheme

In order to achieve the purpose, the invention provides the following technical scheme: a method for dynamically generating a font map comprises the following steps:

s1, generating an initialization bitmap with a blank space of a fixed size according to a preset size by using an operating system default drawing tool;

s2, generating basic control parameters of the dynamic chartlet font by using an operating system default static font tool;

s3, inputting a target text, making a fixed character set for dynamic text mapping, and counting the number MaxTexts of all the character sets;

s4, drawing all characters by using an operating system default static font tool according to the basic regulation and control parameters, generating a character map file for each character, and generating all character map files which are called character map sets for short;

and S5, arranging the character map files in sequence, and drawing in the initialization bitmap by using an operating system drawing tool.

Preferably, the preset size of the initialization bitmap in step S1 may be according to a display memory of a currently mainstream mobile GPU display card, where the preset size is generally 512 × 512 pixels, and may also be adjusted to other sizes as needed.

Preferably, the basic control parameters in step S2 include: font name, font size.

Preferably, the character set in step S3 is not changeable after generating the font map.

Preferably, the method further includes S6, and pre-generating effects such as bold, italic, drawing, shading, etc. for each character map according to the tool provided by the operating system, where the adding effect may cause the size of the original character map to change, and at this time, the size of each character map needs to be recalculated.

Preferably, the method further includes S7, in order to save the size of the output bitmap, the arrangement of the character pasting set may be optimized as follows:

s71, sorting the character paste picture set, wherein the strategy of blood discharging can be specified, and the strategies can be selected as follows: the area, width, height, and the most lateral side of each character map;

s72, according to the size of a display memory of a modern mobile hardware GPU display card, predesignating the sizes of 128 multiplied by 128, 256 multiplied by 256, 256 multiplied by 128, 512 multiplied by 512, 1024 multiplied by 1024, 1024 multiplied by 2048, 2048 multiplied by 4096, 4096 multiplied by 4096 and the like as an output bitmap size set;

s73, according to the sequence of the output bitmap size set, sequentially trying whether each size can be filled and placed into all the character paste sets in sequence, at the moment, the character paste sets are already sorted, each time one character paste is placed, dividing the bitmap into a large space and a small space, and iteratively filling all the remaining character paste sets into the two spaces;

and S74, generating a configuration file, and recording the coordinates and size information of all the character strings in the character set corresponding to the map in the output bitmap.

Preferably, the dynamic generating device of the font map comprises a character set input module, a character set generating module and a character generating module, wherein the character set input module is used for generating character sets of languages including Chinese, Japanese, Korean, English and the like; the font chartlet design module is used for setting the regulation and control parameters of the font chartlet, such as the size, the thickening, the italics, the drawing, the shadow and the like according to the font tool of the operating system; and the bitmap generation module is used for outputting a font chartlet with the minimum size and a corresponding configuration file according to the size of the video memory of the modern mobile hardware GPU video card and the character chartlet set based on the input of the specified character set.

Preferably, the computer program is stored on a computer readable storage medium, and when executed by a processor, the computer program implements a method for dynamically generating a font map.

(III) advantageous effects

The invention provides a method and a device for dynamically generating a font chartlet and a readable storage medium, which have the following beneficial effects:

the dynamic generation method, the device and the readable storage medium of the font chartlet provided by the invention provide a dynamic generation mode of the personalized font chartlet, and a producer finishes the pre-drawing work of artistic fonts in advance and stores the artistic fonts in the readable storage medium.

Drawings

FIG. 1 is a flow chart of a method for dynamically generating a font map in accordance with the present invention;

FIG. 2 is a diagram of a character map set according to the present invention;

FIG. 3 is a schematic diagram of the present invention depicting character map padding in an initialization bitmap;

FIG. 4 is a flow chart of a method of calculating a minimum bitmap size according to the present invention;

FIG. 5 is a schematic diagram of the segmentation of the original bitmap space each time a charset chartlet is filled in, when calculating the minimum bitmap size according to the present invention;

FIG. 6 is a schematic diagram of an apparatus for dynamically generating a font map according to the present invention;

FIG. 7 is another schematic diagram of the dynamic generation apparatus of the body map of the present invention;

fig. 8 is a schematic structural diagram of an electronic device according to the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Example 1

As shown in fig. 1, the present invention provides a method for dynamically generating a font map, which is executed by a device for dynamically generating a font map, the device is implemented by software and/or hardware, and is specifically configured and equipped in an electronic device with mobile data computing capability, and the method specifically includes the following steps:

1. generating a blank initialization bitmap according to a preset size;

2. adjusting font parameters: font name, font size;

3. inputting and generating a fixed character set;

4. drawing all characters by using a font tool to generate a character paste picture set;

5. filling and drawing the character paste picture set in the initialization bitmap according to a certain sequence;

6. and generating and storing a character set mapping configuration file.

In this embodiment, a character mapping set is generated, and the characters in the fixed character set are split into pixel bitmaps in time for display, so as to implement dynamic rendering, as shown in fig. 2, "ABCD" is used as the fixed character set, and "a", "B", "C", "D" 4 mapping files with different sizes are generated, and in places where effects such as color, thickness, shadow, and edge tracing need to be added, the font files are rendered into image files to implement display of the text, so as to attract users well.

The final output file in this embodiment is composed of a configuration file of font maps and a bitmap file storing all character map sets, as shown in fig. 3, samples drawn into bitmaps are filled according to the character map set of fig. 2 and the final optimized positions, and "a", "B", "C", and "D" 4 map files are filled and merged into a fixed-size map file, and according to the design, each character is converted into a picture, sorted by size, and filled and stored in a fixed-size bitmap file after being corrected.

In the configuration file finally output in this embodiment, at least the character code corresponding to each character in the character set, the coordinate information and the size information of the character map in the bitmap are included, and each character occupies a row of the configuration file in sequence, for example: the profile corresponding to "char id ═ u534 e' x ═ 0 y ═ 0 width ═ 33 height ═ 36" shows that the chinese character "hua" corresponding to the Unicode code "\\ u534 e" is located at the (0, 0) coordinates, the size of the map is 33 pixels, and the width is 36 pixels.

In this embodiment, the character encoding of the character set may follow Unicode international encoding to support all languages including chinese, japanese, korean, english, and the like. Unicode is an industry standard in the field of computer science and includes character sets, coding schemes, and the like. Unicode is generated to solve the limitation of the traditional character encoding scheme, and sets a uniform and unique binary code for each character in each language so as to meet the requirements of cross-language and cross-platform text conversion and processing.

Example 2

As shown in fig. 4, the present invention provides a method for calculating the minimum bitmap size, which comprises the following steps:

1. sorting the character paste picture set;

2. adjusting the size of the output bitmap according to a preset sequence;

3. filling and putting all character paste picture sets to the bitmap size in sequence;

4. it is detected whether the size exceeds the maximum size.

In step 4, if the maximum size is exceeded, step 2 is repeated, using a one-step larger bitmap size.

In this embodiment, the unit of the bitmap size is a pixel, and the pre-specified size may be 128 × 128, 256 × 256, 256 × 128, 512 × 512, 1024 × 1024, 1024 × 2048, 2048 × 4096, 4096 × 4096, or the like according to the size of the display memory of the graphics card of the modern mobile hardware GPU.

In this embodiment, it is necessary to sort the character tile set, and for practical operation, different sorting strategies have very large effect differences under different character sizes, which is mainly reflected in that the width proportion of the final output bitmap is different. The policy of the ordering may be specified, and the policy may be selected to be: the area, width, height and the most lateral side of each character map are sequencing basis.

In this embodiment, each time a character map is placed, the bitmap is divided into a large space and a small space, and as shown in fig. 5, all the remaining character map sets that have been sorted need to be iteratively filled into the large space and the small space, so that the merging work of all the character map sets can be completed.

In this embodiment, it is necessary to merge all the character set maps into one bitmap. In practice, other fonts such as chinese contain a large number of characters, and if all character set maps are not merged, a large number of scattered maps will be generated, resulting in a reduction in the performance of mobile rendering.

Example 3

As shown in fig. 6, the present invention provides a dynamic generation apparatus for font maps, which specifically includes:

a character set input module: the system is used for generating character sets of languages including Chinese, Japanese, Korean, English and the like;

font chartlet design module: the character size of the font chartlet is set according to the font tool of the operating system, and the regulation and control parameters such as thickening, italics, drawing, shadow and the like are set;

a bitmap generation module: the method is used for outputting the font chartlet with the minimum size and the corresponding configuration file according to the size of the video memory of the modern mobile hardware GPU video card based on the input of the specified character set and the character chartlet set.

The font mapping drawing apparatus of this embodiment implements dynamic drawing of the font mapping by using the above modules, which is the same as the implementation principle of the above related method embodiment, and reference may be made to the description of the related method embodiment in detail, and details are not repeated here.

Example 4

As shown in fig. 7, the present invention provides a dynamic font chartlet generation apparatus, and the structural principle of the apparatus is further described in detail on the basis of fig. 6.

In the dynamic generation apparatus for font maps of this embodiment, the map preview module is specifically configured to display a real-time rendering effect of the font map in time according to the configuration file and the actual bitmap map.

In this embodiment, in actual operation, the map preview module generally displays 26 letters and 10 numbers 0-9, and does not display non-English letters such as Chinese, Japanese, Korean, etc. by default.

Optionally, the map preview module may detect whether the character set includes non-english letters such as chinese, japanese, korean, and the like, and when the detection is true, may intercept the first few characters input by the user for implementing the map preview. Because the character encoding of the character set is Unicode international encoding, the character sets of Chinese, Japanese, Korean and the like are in specific encoding bits in the Unicode encoding, and whether the character set contains non-English letters of Chinese, Japanese, Korean and the like or not can be detected according to the input Unicode encoding.

Further optionally, due to the addition of the map preview module, other configuration options can be added to the character configuration. In actual operation, the alpha value of the map edge is difficult to be accurately calculated due to the edge tracing and shadow effects, and can be corrected by adjusting configuration options such as the inner and outer margins of the character set, and the specific implementation configuration files include: "char id ═ u534 e' x ═ 0 y ═ 0 width ═ 33 height ═ 36 xoffset ═ 0 yoifset ═ 28", the corresponding profile indicates that the chinese character "hua" corresponding to Unicode code "\ u534 e" is located at the (0, 0) coordinate, the size of the map is 33 pixels, the width is 36 pixels, the x coordinate is offset by 0 pixels, and the y coordinate is offset by 28 pixels.

Example 5

As shown in fig. 8, the present invention provides an electronic device comprising an input device, an output device, a processor, and a memory, wherein:

an input device: the method comprises the steps of obtaining an input character set;

an output device: used for displaying the font map;

one or more processors;

a memory: for storing one or more programs.

In this embodiment, a processor is taken as an example, the input device in the electronic apparatus may be connected to the output device, the processor and the memory through a bus or other manners, and the processor and the memory are also connected through a bus or other manners, which is taken as an example in this embodiment.

In this embodiment, a processor in the electronic device may control the input device to obtain an input character set; font parameters may also be adjusted: font name, font size, bold, italic, outline, shadow, etc. of the font chartlet; the output device may also be controlled to present the font map.

The memory in the electronic device, which is a computer-readable storage medium, may be used to store one or more programs, which may be software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the dynamic generation method of the font map in the embodiment of the present invention. The processor executes various functional applications and data processing of the electronic device by running software programs, instructions and modules stored in the storage device, that is, the dynamic generation method of the font map in the above method embodiment is realized.

The storage device may include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for a function; the storage data area may store data and the like (such as the font maps and the configuration files in the above-described embodiments). In some examples, the storage device may further include memory located remotely from the processor, which may be connected to the server over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.

Example 6

The present invention provides a storage medium containing computer-executable instructions which, when executed by a computer processor, perform a method for dynamic generation of a font map, the method comprising:

1. generating an initialization bitmap with a blank of a fixed size according to a preset size, and adjusting the initialization bitmap to other sizes as required;

2. generating basic regulation and control parameters of the font of the dynamic chartlet: font name, font size;

3. inputting a target text and making a fixed character set for dynamic text chartlet;

4. according to basic regulation and control parameters: the method comprises the following steps of (1) drawing all characters according to font names and character sizes, generating a character map file for each character, and shortening all generated character map files into a character map set;

5. arranging the character map sets according to the sequence, filling and drawing the character map sets in the initialization bitmap, generating a configuration file, and recording the coordinates and the size information of all character strings in the character sets, which correspond to the maps, in the output bitmap.

In this embodiment, a storage medium containing computer-executable instructions is provided, where the computer-executable instructions are not limited to the method operations described above, and may also perform operations related to the method for dynamically generating a font map provided in any embodiment of the present invention.

Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the consumer electronic device, partly on a remote electronic device, or entirely on the remote electronic device or server. In the case of remote electronic devices, the remote electronic devices may be connected to the consumer electronic device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external electronic device (e.g., through the internet using an internet service provider).

From the above description of the embodiments, it is clear to those skilled in the art that the present invention can be implemented by software and necessary general hardware. With this understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.

It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.

Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:自回归语言模型的训练方法、装置、设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!