diff --git a/rosen/modules/2d_graphics/include/c/drawing_text_typography.h b/rosen/modules/2d_graphics/include/c/drawing_text_typography.h index de74427eeb..46c39c4b51 100644 --- a/rosen/modules/2d_graphics/include/c/drawing_text_typography.h +++ b/rosen/modules/2d_graphics/include/c/drawing_text_typography.h @@ -218,7 +218,8 @@ void OH_Drawing_SetTextStyleFontHeight(OH_Drawing_TextStyle*, double /* fontHeig * @param int number of font families * @param char* fontFamilies name */ -void OH_Drawing_SetTextStyleFontFamilies(OH_Drawing_TextStyle*, int /* fontFamiliesNumber */, const char* fontFamilies[]); +void OH_Drawing_SetTextStyleFontFamilies(OH_Drawing_TextStyle*, + int /* fontFamiliesNumber */, const char* fontFamilies[]); /** * @brief set typography font style. @@ -244,7 +245,8 @@ void OH_Drawing_SetTextStyleLocale(OH_Drawing_TextStyle*, const char*); * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @return a pointer to created OH_Drawing_TypographyCreate */ -OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler(OH_Drawing_TypographyStyle*, OH_Drawing_FontCollection*); +OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler(OH_Drawing_TypographyStyle*, + OH_Drawing_FontCollection*); /** * @brief Release the memory storing the OH_Drawing_TypographyCreate object. @@ -314,7 +316,8 @@ void OH_Drawing_TypographyLayout(OH_Drawing_Typography*, double /* maxWidth */); * @param double position X * @param double position Y */ -void OH_Drawing_TypographyPaint(OH_Drawing_Typography*, OH_Drawing_Canvas*, double /* potisionX */, double /* potisionY */); +void OH_Drawing_TypographyPaint(OH_Drawing_Typography*, OH_Drawing_Canvas*, + double /* potisionX */, double /* potisionY */); #ifdef __cplusplus } diff --git a/rosen/modules/2d_graphics/src/c/drawing_text_typography.cpp b/rosen/modules/2d_graphics/src/c/drawing_text_typography.cpp index 4a3de2f303..c80ef35bbe 100644 --- a/rosen/modules/2d_graphics/src/c/drawing_text_typography.cpp +++ b/rosen/modules/2d_graphics/src/c/drawing_text_typography.cpp @@ -13,9 +13,9 @@ * limitations under the License. */ +#include "c/drawing_text_typography.h" #include "c/drawing_text_convertor.h" -#include "c/drawing_text_typography.h" #include "rosen_text/ui/font_collection.h" #include "rosen_text/ui/typography.h" #include "rosen_text/ui/typography_create.h" @@ -37,7 +37,7 @@ void OH_Drawing_DestroyTypographyStyle(OH_Drawing_TypographyStyle* style) void OH_Drawing_SetTypographyTextDirection(OH_Drawing_TypographyStyle* style, int direction) { rosen::TextDirection textDirection; - switch(direction) { + switch (direction) { case TEXT_DIRECTION_RTL: { textDirection = rosen::TextDirection::RTL; break; @@ -57,7 +57,7 @@ void OH_Drawing_SetTypographyTextDirection(OH_Drawing_TypographyStyle* style, in void OH_Drawing_SetTypographyTextAlign(OH_Drawing_TypographyStyle* style, int align) { rosen::TextAlign textAlign; - switch(align) { + switch (align) { case TEXT_ALIGN_LEFT: { textAlign = rosen::TextAlign::LEFT; break; @@ -217,7 +217,8 @@ void OH_Drawing_SetTextStyleFontHeight(OH_Drawing_TextStyle* style, double fontH ConvertToOriginalText(style)->height_ = fontHeight; } -void OH_Drawing_SetTextStyleFontFamilies(OH_Drawing_TextStyle* style, int fontFamiliesNumber, const char* fontFamilies[]) +void OH_Drawing_SetTextStyleFontFamilies(OH_Drawing_TextStyle* style, + int fontFamiliesNumber, const char* fontFamilies[]) { std::vector rosenFontFamilies; for (int i = 0; i < fontFamiliesNumber; i++) { diff --git a/rosen/samples/text/renderservice/drawing_text_c_sample.cpp b/rosen/samples/text/renderservice/drawing_text_c_sample.cpp index dad1fe48b4..1597ffce39 100644 --- a/rosen/samples/text/renderservice/drawing_text_c_sample.cpp +++ b/rosen/samples/text/renderservice/drawing_text_c_sample.cpp @@ -68,17 +68,19 @@ void DoDraw(uint8_t *addr, uint32_t width, uint32_t height, size_t index) OH_Drawing_Canvas* cCanvas = OH_Drawing_CanvasCreate(); OH_Drawing_CanvasBind(cCanvas, cBitmap); - OH_Drawing_CanvasClear(cCanvas,OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF)); + OH_Drawing_CanvasClear(cCanvas, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF)); OH_Drawing_TypographyStyle* typoStyle = OH_Drawing_CreateTypographyStyle(); OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_LTR); OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_LEFT); - OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, OH_Drawing_CreateFontCollection()); + OH_Drawing_TypographyCreate* handler = OH_Drawing_CreateTypographyHandler(typoStyle, + OH_Drawing_CreateFontCollection()); OH_Drawing_TextStyle* txtStyle = OH_Drawing_CreateTextStyle(); OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0x00, 0x00, 0x00)); - OH_Drawing_SetTextStyleFontSize(txtStyle, 80); + double fontSize = 30; + OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize); OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400); OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC); OH_Drawing_SetTextStyleFontHeight(txtStyle, 1); @@ -168,14 +170,15 @@ int main() auto surfaceNode = CreateSurface(); RSDisplayNodeConfig config; RSDisplayNode::SharedPtr displayNode = RSDisplayNode::Create(config); - for (size_t i = 0; i < 5; i++) { - sleep(2); + int testNumber = 5; + for (size_t i = 0; i < testNumber; i++) { + int restTime = 4; + sleep(restTime); displayNode->AddChild(surfaceNode, -1); surfaceNode->SetBounds(0, 0, WIDTH, HEIGHT); RSTransactionProxy::GetInstance()->FlushImplicitTransaction(); DrawSurface(surfaceNode, WIDTH, HEIGHT, i); - // sleep 8s - sleep(4); + sleep(restTime); displayNode->RemoveChild(surfaceNode); RSTransactionProxy::GetInstance()->FlushImplicitTransaction(); }