Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to draw text with UGL

Shulou Source: shulou.com Published: 2022-06-01 09:50:39 10月22日 Update

This article will explain in detail how to draw text on UGL. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

First, refer to the previous operation of opening the display device, use uglRegistryFind () to find the font engine; then use uglFontFindString () to find the desired font; use uglFontCreate () to create a local font; use uglFontSet () to tell the current graphic context; finally, use uglTextDraw () to draw the text

The code is as follows, but lines 5 or 6

Multiple local fonts can be created in an App. Just tell GC through uglFontSet () before drawing the text.

The foreground color of GC refers to the color of the pixels occupied by each stroke in the character; the background color is the color of the rectangular area occupied by each character.

If the color is not set for GC, then GC will use the previous value, and when the system starts up, the initial value of the GC member is 0, so it is black

There are several related functions.

When uglTextDraw () draws text, the characters are aligned to BaseLine by default, roughly the lower-left corner of each character. In general, App needs to be aligned to the upper left corner, so you can use uglFontDriverInfo () to set the starting position of the entire font when drawing characters.

Or use uglFontInfo () to set a single font

You can use uglFontMetricsGet () to query font details

Use uglTextSizeGet () to calculate the space occupied by a piece of text when using a font, which makes it easier to calculate the position of uglTextDrawW ()

If you want to use double-byte encoded Asian fonts (such as Chinese), use the matching uglTextSizeGetW () and uglTextDrawW

This is the end of the article on "how to draw text in UGL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Font text character article color position font more reference different good practical upper and lower context code information pixels content function initial value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information Docker Xiaomi Linux