Skip to content

Commit

Permalink
1,修改miter显示字母只多出来的箭头
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Jun 5, 2023
1 parent 92efd9c commit e2afc18
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@

### 属性一览

| attr | format | description |
|-----------------------------|:---------------:|:--------------------------------------------------------------:|
| gradient_startColor | color/reference | 前景字体渐变颜色开始颜色 |
| gradient_centerColor | color/reference | 前景字体渐变颜色中心颜色 |
| gradient_endColor | color/reference | 前景字体渐变颜色结束颜色 |
| gradient_angle | float | 前景字体渐变颜色开始角度 |
| gradient_rtl_angle | boolean | 前景字体渐变颜色开始角度是否支持镜像Rtl适配 |
| gradient_stroke_startColor | color/reference | 字体粗边渐变颜色开始颜色 |
| gradient_stroke_centerColor | color/reference | 字体粗边渐变颜色中心颜色 |
| gradient_stroke_endColor | color/reference | 字体粗边渐变颜色结束颜色 |
| gradient_stroke_angle | float | 字体粗边渐变颜色开始角度 |
| gradient_stroke_rtl_angle | boolean | 字体粗边渐变颜色开始角度是否支持镜像Rtl适配 |
| gradient_stroke_strokeWidth | dimension | 字体粗边画笔宽度 |
| gradient_stroke_textColor | color/reference | 字体粗边颜色(设置粗边渐变色之后此属性无效,设置此属性后粗边渐变色也失效) |
| gradient_stroke_join | enum | 字体粗边样式 round/bevel/miter 具体效果自行尝试(不建议使用miter,因为目前发现部分英文字母出现尖头) |
| attr | format | description |
|-----------------------------|:---------------:|:-------------------------------------:|
| gradient_startColor | color/reference | 前景字体渐变颜色开始颜色 |
| gradient_centerColor | color/reference | 前景字体渐变颜色中心颜色 |
| gradient_endColor | color/reference | 前景字体渐变颜色结束颜色 |
| gradient_angle | float | 前景字体渐变颜色开始角度 |
| gradient_rtl_angle | boolean | 前景字体渐变颜色开始角度是否支持镜像Rtl适配 |
| gradient_stroke_startColor | color/reference | 字体粗边渐变颜色开始颜色 |
| gradient_stroke_centerColor | color/reference | 字体粗边渐变颜色中心颜色 |
| gradient_stroke_endColor | color/reference | 字体粗边渐变颜色结束颜色 |
| gradient_stroke_angle | float | 字体粗边渐变颜色开始角度 |
| gradient_stroke_rtl_angle | boolean | 字体粗边渐变颜色开始角度是否支持镜像Rtl适配 |
| gradient_stroke_strokeWidth | dimension | 字体粗边画笔宽度 |
| gradient_stroke_textColor | color/reference | 字体粗边颜色(设置粗边渐变色之后此属性无效,设置此属性后粗边渐变色也失效) |
| gradient_stroke_join | enum | 字体粗边样式 round/bevel/miter 具体效果自行尝试 |



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class GradientTextView extends PerfectTextView {
private ColorStateList strokeTextColor;
private int curStrokeTextColor;
private Paint.Join strokeJoin;
private Float defaultStrokeMiter;

public GradientTextView(Context context) {
this(context, null);
Expand Down Expand Up @@ -225,6 +226,14 @@ protected void onDraw(Canvas canvas) {
textPaint.setStrokeWidth(strokeWidth);
textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
textPaint.setStrokeJoin(strokeJoin);
if (defaultStrokeMiter == null){
defaultStrokeMiter = textPaint.getStrokeMiter();
}
if (strokeJoin == Paint.Join.MITER){
textPaint.setStrokeMiter(2.6f);
}else {
textPaint.setStrokeMiter(defaultStrokeMiter);
}
LinearGradient linearGradient;
if (gradientStrokeColor){
float currentAngle = strokeAngle;
Expand Down

0 comments on commit e2afc18

Please sign in to comment.