@@ -4,6 +4,7 @@ import android.content.Context
44import android.graphics.*
55import android.graphics.drawable.Drawable
66import android.support.annotation.FloatRange
7+ import android.support.v4.content.res.ResourcesCompat
78import android.support.v4.view.ViewCompat
89import android.text.Layout
910import android.text.StaticLayout
@@ -250,6 +251,30 @@ class StatusView @JvmOverloads constructor(
250251 mTextPaintStatus.textSize = textSizeStatus
251252 }
252253
254+ /* *
255+ * Text Font of statuses
256+ */
257+
258+ var statusTypeface: Typeface ? by OnLayoutProp (null ){
259+ statusTypeface?.run {
260+ mTextPaintStatus.typeface = this
261+ }
262+
263+ }
264+
265+ /* *
266+ * Text Font of Labels
267+ */
268+
269+ var labelsTypeface: Typeface ? by OnLayoutProp (null ){
270+ labelsTypeface?.run {
271+ mTextPaintLabels.typeface = this
272+ mTextPaintLabelsIncomplete.typeface = this
273+ mTextPaintLabelCurrent.typeface = this
274+ }
275+
276+ }
277+
253278 /* *
254279 * A boolean which decides if to draw labels or not
255280 */
@@ -412,6 +437,24 @@ class StatusView @JvmOverloads constructor(
412437 }
413438 }
414439
440+ try {
441+ val resource: Int = a.getResourceId(R .styleable.StatusView_statusFont , - 1 )
442+ if (resource != - 1 ) {
443+ statusTypeface = ResourcesCompat .getFont(getContext(), resource)
444+ }
445+ } catch (e: Exception ) {
446+ e.printStackTrace()
447+ }
448+
449+ try {
450+ val resource: Int = a.getResourceId(R .styleable.StatusView_labelFont , - 1 )
451+ if (resource != - 1 ) {
452+ labelsTypeface = ResourcesCompat .getFont(getContext(), resource)
453+ }
454+ } catch (e: Exception ) {
455+ e.printStackTrace()
456+ }
457+
415458
416459 } finally {
417460 a.recycle()
@@ -434,16 +477,19 @@ class StatusView @JvmOverloads constructor(
434477 mTextPaintStatus.textAlign = Paint .Align .CENTER
435478 mTextPaintStatus.color = textColorStatus
436479 mTextPaintStatus.textSize = textSizeStatus
437-
438-
480+ statusTypeface?.run {
481+ mTextPaintStatus.typeface = this
482+ }
439483
440484 mLinePaintIncomplete = Paint (mLinePaint)
441485 mLinePaintIncomplete.color = lineColorIncomplete
442486
443487 mLinePaintCurrent = Paint (mLinePaint)
444488 mLinePaintCurrent.color = lineColorCurrent
445489
446- mTextPaintLabels = TextPaint (mTextPaintStatus)
490+ mTextPaintLabels = TextPaint (Paint .ANTI_ALIAS_FLAG )
491+ mTextPaintLabels.style = Paint .Style .FILL
492+ mTextPaintLabels.textAlign = Paint .Align .CENTER
447493 mTextPaintLabels.textSize = textSizeLabels
448494 mTextPaintLabels.color = textColorLabels
449495
@@ -454,6 +500,13 @@ class StatusView @JvmOverloads constructor(
454500 mTextPaintLabelCurrent = TextPaint (mTextPaintLabels)
455501 mTextPaintLabelCurrent.color = textColorLabelCurrent
456502
503+ labelsTypeface?.run {
504+ mTextPaintLabels.typeface = this
505+ mTextPaintLabelsIncomplete.typeface = this
506+ mTextPaintLabelCurrent.typeface = this
507+ }
508+
509+
457510
458511 }
459512
@@ -533,7 +586,7 @@ class StatusView @JvmOverloads constructor(
533586 }
534587
535588 if (isShowingCurrentStatus()){
536- extraWidth + = (currentStatusRadius- circleRadius)* 2 ;
589+ extraWidth + = (currentStatusRadius- circleRadius)* 2
537590 }
538591
539592
@@ -838,7 +891,7 @@ class StatusView @JvmOverloads constructor(
838891 circleRadius = currentStatusRadius
839892 }
840893
841- return (2 * circleRadius + circleStrokeWidth) + lineWidth;
894+ return (2 * circleRadius + circleStrokeWidth) + lineWidth
842895 }
843896
844897 private fun minStatusWidthExtremes (pos : Int ): Float {
0 commit comments