From 8880d2332dbf23e858ffa293663f145bdedf7091 Mon Sep 17 00:00:00 2001 From: ZY_encoder Date: Tue, 13 May 2025 13:48:47 +0800 Subject: [PATCH] Support high contrast setting on APP Signed-off-by: ZY_encoder --- graphic/graphic_2d/native_drawing/BUILD.gn | 2 + .../native_drawing/drawing_text_global.h | 76 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 4 + 3 files changed, 82 insertions(+) create mode 100644 graphic/graphic_2d/native_drawing/drawing_text_global.h diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index 88c0459bc..73dbebd12 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -51,6 +51,7 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_blob.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_declaration.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_font_descriptor.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_global.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_line.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_lineTypography.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_run.h", @@ -106,5 +107,6 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_text_typography.h", "native_drawing/drawing_typeface.h", "native_drawing/drawing_types.h", + "native_drawing/drawing_text_global.h", ] } diff --git a/graphic/graphic_2d/native_drawing/drawing_text_global.h b/graphic/graphic_2d/native_drawing/drawing_text_global.h new file mode 100644 index 000000000..7a7493c94 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_text_global.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides the global text capability. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 20 + * @version 1.0 + */ + +/** + * @file drawing_text_global.h + * + * @brief Declares functions related to run in the drawing module. + * + * @kit ArkGraphics2D + * @library libnative_drawing.so + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @since 20 + * @version 1.0 + */ + +#ifndef DRAWING_TEXT_GLOBAL_H +#define DRAWING_TEXT_GLOBAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines text rendering high contrast mode to enhance readability. + * @since 20 + * @version 1.0 + */ +typedef enum { + /** Follow system's high contrast settings for text rendering */ + TEXT_FOLLOW_SYSTEM_HIGH_CONTRAST, + /** Disable high contrast rendering regardless of system settings */ + TEXT_APP_DISABLE_HIGH_CONTRAST, + /** Enable high contrast rendering regardless of system settings */ + TEXT_APP_ENABLE_HIGH_CONTRAST +} OH_Drawing_TextHighContrast; + + +/** + * @brief Sets high contrast mode of text rendering. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param action OH_Drawing_TextHighContrast object. + * @since 20 + */ +void OH_Drawing_SetTextHighContrast(OH_Drawing_TextHighContrast action); + +#ifdef __cplusplus +} +#endif +#endif // DRAWING_TEXT_GLOBAL_H + +/** @} */ \ No newline at end of file diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index d39f4f1c0..dcde9e7af 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1797,5 +1797,9 @@ { "first_introduced": "20", "name": "OH_Drawing_SetTextStyleBadgeType" + }, + { + "first_introduced": "20", + "name": "OH_Drawing_SetTextHighContrast" } ] \ No newline at end of file -- Gitee