2017-07-05 23:10:57 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions defined in
|
|
|
|
* file 'LICENSE.md', which is part of this source code package.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package fonts
|
|
|
|
|
|
|
|
import (
|
2018-10-09 11:49:59 +11:00
|
|
|
"fmt"
|
|
|
|
|
2019-05-16 23:44:51 +03:00
|
|
|
"github.com/unidoc/unipdf/v3/internal/textencoding"
|
2017-07-05 23:10:57 +00:00
|
|
|
)
|
|
|
|
|
2018-06-27 12:25:59 +10:00
|
|
|
// Font represents a font which is a series of glyphs. Character codes from PDF strings can be
|
2019-03-09 20:45:19 +00:00
|
|
|
// mapped to and from glyphs. Each glyph has metrics.
|
2017-07-05 23:10:57 +00:00
|
|
|
type Font interface {
|
2017-09-01 13:20:51 +00:00
|
|
|
Encoder() textencoding.TextEncoder
|
2018-12-28 01:38:48 +02:00
|
|
|
GetRuneMetrics(r rune) (CharMetrics, bool)
|
2017-07-05 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
2017-09-01 13:20:51 +00:00
|
|
|
// CharMetrics represents width and height metrics of a glyph.
|
2017-07-05 23:10:57 +00:00
|
|
|
type CharMetrics struct {
|
2018-12-26 19:00:38 +02:00
|
|
|
Wx float64
|
2018-12-26 19:03:15 +02:00
|
|
|
Wy float64 // TODO(dennwc): none of code paths sets this to anything except 0
|
2017-07-05 23:10:57 +00:00
|
|
|
}
|
2018-09-19 11:12:59 +10:00
|
|
|
|
2018-10-09 11:49:59 +11:00
|
|
|
func (m CharMetrics) String() string {
|
2018-12-26 19:00:38 +02:00
|
|
|
return fmt.Sprintf("<%.1f,%.1f>", m.Wx, m.Wy)
|
2018-10-09 11:49:59 +11:00
|
|
|
}
|