# Ohos-Iconics
**Repository Path**: chinasoft5_ohos/Ohos-Iconics
## Basic Information
- **Project Name**: Ohos-Iconics
- **Description**: Ohos-Iconics - Use any icon font, or vector (.svg) as drawable in your application.
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2021-06-22
- **Last Updated**: 2021-12-15
## Categories & Tags
**Categories**: harmonyos-image
**Tags**: None
## README
# Ohos-Iconics
#### 项目介绍
- 项目名称:Ohos-Iconics
- 所属系列:openharmony的第三方组件适配移植
- 功能:可设置颜色,线框,阴影等定制化功能的矢量字体图标库
- 项目移植状态:主功能完成,不支持Text设置spannable,不支持xml中使用IconicsDrawable,不支持LayoutInflater.Factory2替换自定义组件,不支持Jetpack Compose中使用该库,不支持Jetpack Startup初始化字体库
- 调用差异:无
- 开发版本:sdk6,DevEco Studio2.2 Beta1
- 基线版本:Release v5.3.0-b01
#### 效果演示
#### 安装教程
1.在项目根目录下的build.gradle文件中,
```gradle
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
}
}
}
```
2.在entry模块的build.gradle文件中,
```gradle
dependencies {
implementation('com.gitee.chinasoft_ohos:iconics_core:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:iconics_views:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:iconics_typeface_api:0.0.1-SNAPSHOT')
// 下面的字体库选择自己需要的进行依赖
implementation('com.gitee.chinasoft_ohos:weather_icons_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:typeicons_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:pixeden7stroke_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:phosphor_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:octicons_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:meteocons_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:ionicons_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:foundation_icons_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:fontawesome_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:entypo_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:devicon_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:community_material_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:material_design_iconic_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:material_design_dx_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:google_material_typeface:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:google_material_typeface_outlined:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:google_material_typeface_rounded:0.0.1-SNAPSHOT')
implementation('com.gitee.chinasoft_ohos:google_material_typeface_sharp:0.0.1-SNAPSHOT')
......
}
```
在sdk6,DevEco Studio2.2 Beta1下项目可直接运行
如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
#### 使用说明
1. 使用IconicsDrawable
```java
IconicsImageView image = new IconicsImageView(this);
IconicsDrawable drawable = new IconicsDrawable(image, this, FontAwesome.Icon.faw_adjust);
drawable.setColor(Color.RED);
drawable.setSize(24);
image.setIcon(drawable);
```
2. 使用IconicsImageView
```java
```
3. 使用IconicsTextView
```java
```
4. 使用IconicsButton
```java
```
5. 注册字体图标
```java
public class MyApplication extends AbilityPackage {
@Override
public void onInitialize() {
super.onInitialize();
// 注册依赖使用的字体图标库
com.mikepenz.iconics.typeface.library.weathericons.Initializer.init(getContext());
com.mikepenz.iconics.typeface.library.typeicons.Initializer.init(getContext());
......
// 注册本地自定义字体图标
CustomFont customFont = CustomFont.getInstance();
Iconics.getInstance().registerFont(customFont);
}
}
```
6. 使用字符串icon-key或者枚举typeface构建字体图标
```java
IconicsDrawable drawable = new IconicsDrawable(component, this, "faw-adjust");
drawable.actionBar();
IconicsDrawable drawable = new IconicsDrawable(component, this, FontAwesome.Icon.faw_adjust);
drawable.setSize(24);
drawable.setPaddingPx(1);
```
#### 测试信息
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
#### 版本迭代
- 0.0.1-SNAPSHOT
#### 版权和许可信息
Copyright 2021 Mike Penz
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.