-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using clustering model for the text width estimation #594
Conversation
|
||
private fun getFaceCoefficient(font: Font): Double { | ||
return when { | ||
font.isBold && font.isItalic -> 0.9172120995070999 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how bold-italic style can have coefficient 0.9 and just italic - only 0.18?
Why "normal" coefficient is near 0.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an additive coefficient.
So, coeff(italic) + coeff(bold)
is approximately equal to coeff(bold-italic)
.
And coeff(normal)
should be zero, but it is just almost zero because of calculations (face coefficient calculated after the family coefficient).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think a correction by e-17 makes any difference?
private const val SIZE_COEFFICIENT = 0.9843304096547842 | ||
|
||
private fun getCharWidth(char: Char): Double { | ||
val clusterId = CLUSTERS.indexOfFirst { char in it } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let use a hash map for the symbol lookup.
Init the hash map using elements of the CLUSTERS
list.
private const val DEFAULT_FAMILY = "Lucida Grande" | ||
private const val DEFAULT_FONT_SIZE = 14 | ||
|
||
private val CLUSTERS = listOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a reference on GitHub: https://github.com/ASmirnov-HORIS/text-width-estimation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I added it, but a bit higher.
@@ -12,6 +12,7 @@ class FontFamily private constructor(private val myName: String) { | |||
} | |||
|
|||
companion object { | |||
val DEFAULT_FONT_FAMILY = forName("\"Lucida Grande\", sans-serif") | |||
val MONOSPACED = forName("monospace") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, does "monospace" family work. Would be nice if it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It work.
But this particular variable is never used.
No description provided.