1 /* 2 * Copyright (c) 2020-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GRAPHIC_LITE_DRAW_LABEL_H 17 #define GRAPHIC_LITE_DRAW_LABEL_H 18 19 #include "common/typed_text.h" 20 #include "draw/draw_utils.h" 21 #include "gfx_utils/geometry2d.h" 22 #include "gfx_utils/heap_base.h" 23 #include "gfx_utils/style.h" 24 25 namespace OHOS { 26 class DrawLabel : public HeapBase { 27 public: 28 static uint16_t DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInfo& labelLine, 29 uint16_t& letterIndex); 30 31 static void DrawArcText(BufferInfo& gfxDstBuffer, const Rect& mask, const char* text, const Point& arcCenter, 32 uint16_t fontId, uint8_t fontSize, const ArcTextInfo arcTextInfo, 33 TextOrientation orientation, const Style& style, uint8_t opaScale, bool compatibilityMode); 34 35 static bool CalculateAngle(uint16_t letterWidth, 36 uint16_t letterHeight, 37 int16_t letterSpace, 38 const ArcTextInfo arcTextInfo, 39 bool xorFlag, 40 uint32_t index, 41 TextOrientation orientation, 42 float& posX, 43 float& posY, 44 float& rotateAngle, 45 float& angle, 46 const Point& arcCenter, 47 bool compatibilityMode); 48 49 static void DrawLetterWithRotate(BufferInfo& gfxDstBuffer, 50 const Rect& mask, 51 uint16_t fontId, 52 uint8_t fontSize, 53 uint32_t letter, 54 const Point& pos, 55 int16_t rotateAngle, 56 const ColorType& color, 57 OpacityType opaScale, 58 bool compatibilityMode); 59 60 static uint8_t GetLineMaxLetterSize(const char* text, uint16_t lineLength, uint16_t fontId, uint8_t fontSize, 61 uint16_t letterIndex, SizeSpan* sizeSpans); 62 static void GetLineBackgroundColor(uint16_t letterIndex, List<LineBackgroundColor>* linebackgroundColor, 63 bool& havelinebackground, ColorType& linebgColor); 64 static void GetBackgroundColor(uint16_t letterIndex, List<BackgroundColor>* backgroundColor, 65 bool& havebackground, ColorType& bgColor); 66 static void GetForegroundColor(uint16_t letterIndex, List<ForegroundColor>* foregroundColor, ColorType& fgColor); 67 static void DrawLineBackgroundColor(BufferInfo& gfxDstBuffer, uint16_t letterIndex, 68 const LabelLineInfo& labelLine); 69 }; 70 } // namespace OHOS 71 #endif // GRAPHIC_LITE_DRAW_LABEL_H 72