mirror of
https://github.com/FossifyOrg/Keyboard.git
synced 2026-05-24 22:35:23 -04:00
feat: add font customization (#380)
This commit is contained in:
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Added support for custom fonts
|
||||
|
||||
### Fixed
|
||||
- Fixed an issue where sound/vibration preferences were ignored after reboot ([#372])
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ import org.fossify.commons.extensions.isDynamicTheme
|
||||
import org.fossify.commons.extensions.lightenColor
|
||||
import org.fossify.commons.extensions.removeUnderlines
|
||||
import org.fossify.commons.extensions.toast
|
||||
import org.fossify.commons.helpers.FontHelper
|
||||
import org.fossify.commons.helpers.HIGHER_ALPHA
|
||||
import org.fossify.commons.helpers.ensureBackgroundThread
|
||||
import org.fossify.commons.helpers.isPiePlus
|
||||
@@ -670,11 +671,12 @@ class MyKeyboardView @JvmOverloads constructor(
|
||||
val paint = mPaint
|
||||
val keys = mKeys
|
||||
paint.color = mTextColor
|
||||
val customTypeface = FontHelper.getTypeface(context)
|
||||
val smallLetterPaint = Paint().apply {
|
||||
set(paint)
|
||||
color = paint.color.adjustAlpha(0.8f)
|
||||
textSize = mTopSmallNumberSize
|
||||
typeface = Typeface.DEFAULT
|
||||
typeface = customTypeface
|
||||
}
|
||||
|
||||
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR)
|
||||
@@ -699,13 +701,13 @@ class MyKeyboardView @JvmOverloads constructor(
|
||||
if (code == KEYCODE_SPACE && key.label.length > 1) {
|
||||
// Use smaller font size for current language label on space bar
|
||||
paint.textSize = mSpaceBarTextSize.toFloat()
|
||||
paint.typeface = Typeface.DEFAULT
|
||||
paint.typeface = customTypeface
|
||||
} else if (label.length > 1) {
|
||||
paint.textSize = mLabelTextSize.toFloat()
|
||||
paint.typeface = Typeface.DEFAULT_BOLD
|
||||
paint.typeface = Typeface.create(customTypeface, Typeface.BOLD)
|
||||
} else {
|
||||
paint.textSize = mKeyTextSize.toFloat()
|
||||
paint.typeface = Typeface.DEFAULT
|
||||
paint.typeface = customTypeface
|
||||
}
|
||||
|
||||
paint.color = textColor
|
||||
@@ -1042,15 +1044,16 @@ class MyKeyboardView @JvmOverloads constructor(
|
||||
if (key.icon != null) {
|
||||
mPreviewText!!.setCompoundDrawables(null, null, null, key.icon)
|
||||
} else {
|
||||
val customTypeface = FontHelper.getTypeface(context)
|
||||
if (key.label.length > 1) {
|
||||
mPreviewText!!.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize.toFloat())
|
||||
mPreviewText!!.typeface = Typeface.DEFAULT_BOLD
|
||||
mPreviewText!!.typeface = Typeface.create(customTypeface, Typeface.BOLD)
|
||||
} else {
|
||||
mPreviewText!!.setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
mPreviewTextSizeLarge.toFloat()
|
||||
)
|
||||
mPreviewText!!.typeface = Typeface.DEFAULT
|
||||
mPreviewText!!.typeface = customTypeface
|
||||
}
|
||||
|
||||
mPreviewText!!.setCompoundDrawables(null, null, null, null)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/normal_margin">
|
||||
|
||||
<android.widget.TextView
|
||||
<org.fossify.commons.views.MyTextView
|
||||
android:id="@+id/change_keyboard"
|
||||
style="@style/ColoredButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -269,7 +269,7 @@
|
||||
android:padding="@dimen/small_margin"
|
||||
android:src="@drawable/ic_arrow_left_vector" />
|
||||
|
||||
<TextView
|
||||
<org.fossify.commons.views.MyTextView
|
||||
android:id="@+id/clipboard_manager_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -303,7 +303,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/clipboard_manager_top_bar">
|
||||
|
||||
<TextView
|
||||
<org.fossify.commons.views.MyTextView
|
||||
android:id="@+id/clipboard_content_placeholder_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -316,7 +316,7 @@
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
<org.fossify.commons.views.MyTextView
|
||||
android:id="@+id/clipboard_content_placeholder_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user