2018-12-07 20:40:53 +02:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions defined in
|
|
|
|
* file 'LICENSE.md', which is part of this source code package.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* The embedded character metrics specified in this file are distributed under the terms listed in
|
|
|
|
* ./afms/MustRead.html.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package fonts
|
|
|
|
|
2018-12-19 13:43:09 +05:00
|
|
|
import "sync"
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RegisterStdFont(CourierName, NewFontCourier)
|
|
|
|
RegisterStdFont(CourierBoldName, NewFontCourierBold)
|
|
|
|
RegisterStdFont(CourierObliqueName, NewFontCourierOblique)
|
|
|
|
RegisterStdFont(CourierBoldObliqueName, NewFontCourierBoldOblique)
|
|
|
|
}
|
|
|
|
|
2018-12-07 20:40:53 +02:00
|
|
|
const (
|
|
|
|
// CourierName is a PDF name of the Courier font.
|
2018-12-19 16:55:27 +05:00
|
|
|
CourierName = StdFontName("Courier")
|
2018-12-07 20:40:53 +02:00
|
|
|
// CourierBoldName is a PDF name of the Courier (bold) font.
|
2018-12-19 16:55:27 +05:00
|
|
|
CourierBoldName = StdFontName("Courier-Bold")
|
2018-12-07 20:40:53 +02:00
|
|
|
// CourierObliqueName is a PDF name of the Courier (oblique) font.
|
2018-12-19 16:55:27 +05:00
|
|
|
CourierObliqueName = StdFontName("Courier-Oblique")
|
2018-12-07 20:40:53 +02:00
|
|
|
// CourierBoldObliqueName is a PDF name of the Courier (bold, oblique) font.
|
2018-12-19 16:55:27 +05:00
|
|
|
CourierBoldObliqueName = StdFontName("Courier-BoldOblique")
|
2018-12-07 20:40:53 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewFontCourier returns a new instance of the font with a default encoder set (WinAnsiEncoding).
|
2018-12-15 18:40:48 +05:00
|
|
|
func NewFontCourier() StdFont {
|
2018-12-19 13:43:09 +05:00
|
|
|
courierOnce.Do(initCourier)
|
|
|
|
return NewStdFont(CourierName, courierCharMetrics)
|
2018-12-07 20:40:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewFontCourierBold returns a new instance of the font with a default encoder set (WinAnsiEncoding).
|
2018-12-15 18:40:48 +05:00
|
|
|
func NewFontCourierBold() StdFont {
|
2018-12-19 13:43:09 +05:00
|
|
|
courierOnce.Do(initCourier)
|
|
|
|
return NewStdFont(CourierBoldName, courierBoldCharMetrics)
|
2018-12-07 20:40:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewFontCourierOblique returns a new instance of the font with a default encoder set (WinAnsiEncoding).
|
2018-12-15 18:40:48 +05:00
|
|
|
func NewFontCourierOblique() StdFont {
|
2018-12-19 13:43:09 +05:00
|
|
|
courierOnce.Do(initCourier)
|
|
|
|
return NewStdFont(CourierObliqueName, courierObliqueCharMetrics)
|
2018-12-07 20:40:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewFontCourierBoldOblique returns a new instance of the font with a default encoder set
|
|
|
|
// (WinAnsiEncoding).
|
2018-12-15 18:40:48 +05:00
|
|
|
func NewFontCourierBoldOblique() StdFont {
|
2018-12-19 13:43:09 +05:00
|
|
|
courierOnce.Do(initCourier)
|
|
|
|
return NewStdFont(CourierBoldObliqueName, courierBoldObliqueCharMetrics)
|
2018-12-07 20:40:53 +02:00
|
|
|
}
|
|
|
|
|
2018-12-19 13:43:09 +05:00
|
|
|
var courierOnce sync.Once
|
|
|
|
|
|
|
|
func initCourier() {
|
2018-12-07 21:33:15 +02:00
|
|
|
// the only font that has same metrics for all glyphs (fixed-width)
|
|
|
|
const wx = 600
|
2018-12-19 13:43:09 +05:00
|
|
|
courierCharMetrics = make(map[GlyphName]CharMetrics, len(type1CommonGlyphs))
|
2018-12-07 21:33:15 +02:00
|
|
|
for _, glyph := range type1CommonGlyphs {
|
2018-12-19 13:43:09 +05:00
|
|
|
courierCharMetrics[glyph] = CharMetrics{GlyphName: glyph, Wx: wx}
|
2018-12-07 21:33:15 +02:00
|
|
|
}
|
|
|
|
// other font variant still have the same metrics
|
2018-12-19 13:43:09 +05:00
|
|
|
courierBoldCharMetrics = courierCharMetrics
|
|
|
|
courierBoldObliqueCharMetrics = courierCharMetrics
|
|
|
|
courierObliqueCharMetrics = courierCharMetrics
|
2018-12-07 21:33:15 +02:00
|
|
|
}
|
2018-12-07 20:40:53 +02:00
|
|
|
|
2018-12-19 13:43:09 +05:00
|
|
|
// courierCharMetrics are the font metrics loaded from afms/Courier.afm. See afms/MustRead.html for
|
2018-12-07 20:40:53 +02:00
|
|
|
// license information.
|
2018-12-19 13:43:09 +05:00
|
|
|
var courierCharMetrics map[GlyphName]CharMetrics
|
2018-12-07 20:40:53 +02:00
|
|
|
|
|
|
|
// Courier-Bold font metrics loaded from afms/Courier-Bold.afm. See afms/MustRead.html for license information.
|
2018-12-19 13:43:09 +05:00
|
|
|
var courierBoldCharMetrics map[GlyphName]CharMetrics
|
2018-12-07 20:47:45 +02:00
|
|
|
|
2018-12-19 13:43:09 +05:00
|
|
|
// courierBoldObliqueCharMetrics are the font metrics loaded from afms/Courier-BoldOblique.afm.
|
2018-12-07 20:47:45 +02:00
|
|
|
// See afms/MustRead.html for license information.
|
2018-12-19 13:43:09 +05:00
|
|
|
var courierBoldObliqueCharMetrics map[GlyphName]CharMetrics
|
2018-12-07 20:47:45 +02:00
|
|
|
|
2018-12-19 13:43:09 +05:00
|
|
|
// courierObliqueCharMetrics are the font metrics loaded from afms/Courier-Oblique.afm.
|
2018-12-07 20:47:45 +02:00
|
|
|
// See afms/MustRead.html for license information.
|
2018-12-19 13:43:09 +05:00
|
|
|
var courierObliqueCharMetrics map[GlyphName]CharMetrics
|