All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.nacular.doodle.drawing.TextMetrics.kt Maven / Gradle / Ivy

There is a newer version: 0.10.4
Show newest version
package io.nacular.doodle.drawing

import io.nacular.doodle.geometry.Size
import io.nacular.doodle.text.StyledText

/**
 * Provides a mechanism to measure the size of various types of text.
 *
 * Created by Nicholas Eddy on 10/30/17.
 *
 * @author Nicholas Eddy
 */
public interface TextMetrics {
    public fun width (text: String, font: Font? = null                                     ): Double
    public fun width (text: String, width: Double, indent: Double = 0.0, font: Font? = null): Double

    public fun width (text: StyledText                                                     ): Double
    public fun width (text: StyledText, width: Double, indent: Double = 0.0                ): Double

    public fun height(text: String, font: Font? = null                                     ): Double
    public fun height(text: String, width: Double, indent: Double = 0.0, font: Font? = null): Double

    public fun height(text: StyledText                                                     ): Double
    public fun height(text: StyledText, width: Double, indent: Double = 0.0                ): Double

    public fun size(text: String, font: Font? = null                                     ): Size = Size(width(text, font), height(text, font))
    public fun size(text: String, width: Double, indent: Double = 0.0, font: Font? = null): Size = Size(width(text, width, indent, font), height(text, width, indent, font))

    public fun size(text: StyledText                                     ): Size = Size(width(text), height(text))
    public fun size(text: StyledText, width: Double, indent: Double = 0.0): Size = Size(width(text, width, indent), height(text, width, indent))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy