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); 34 35 static void DrawLetterWithRotate(BufferInfo& gfxDstBuffer, 36 const Rect& mask, 37 uint16_t fontId, 38 uint8_t fontSize, 39 uint32_t letter, 40 const Point& pos, 41 int16_t rotateAngle, 42 const ColorType& color, 43 OpacityType opaScale); 44 45 static uint8_t GetLineMaxLetterSize(const char* text, uint16_t lineLength, uint16_t fontId, uint8_t fontSize, 46 uint16_t letterIndex, SizeSpan* sizeSpans); 47 static void GetLineBackgroundColor(uint16_t letterIndex, List<LineBackgroundColor>* linebackgroundColor, 48 bool& havelinebackground, ColorType& linebgColor); 49 static void GetBackgroundColor(uint16_t letterIndex, List<BackgroundColor>* backgroundColor, 50 bool& havebackground, ColorType& bgColor); 51 static void GetForegroundColor(uint16_t letterIndex, List<ForegroundColor>* foregroundColor, ColorType& fgColor); 52 static void DrawLineBackgroundColor(BufferInfo& gfxDstBuffer, uint16_t letterIndex, 53 const LabelLineInfo& labelLine); 54 }; 55 } // namespace OHOS 56 #endif // GRAPHIC_LITE_DRAW_LABEL_H 57