equal
deleted
inserted
replaced
166 /* font operations */ |
166 /* font operations */ |
167 |
167 |
168 def font_metrics(font: Font): LineMetrics = |
168 def font_metrics(font: Font): LineMetrics = |
169 font.getLineMetrics("", new FontRenderContext(null, false, false)) |
169 font.getLineMetrics("", new FontRenderContext(null, false, false)) |
170 |
170 |
171 def imitate_font(family: String, font: Font): Font = |
171 def imitate_font(family: String, font: Font, scale: Double = 1.0): Font = |
172 { |
172 { |
173 val font1 = new Font(family, font.getStyle, font.getSize) |
173 val font1 = new Font(family, font.getStyle, font.getSize) |
174 font1.deriveFont(font_metrics(font).getAscent / font_metrics(font1).getAscent * font.getSize) |
174 val size = scale * (font_metrics(font).getAscent / font_metrics(font1).getAscent * font.getSize) |
|
175 font1.deriveFont(size.round.toInt) |
175 } |
176 } |
176 |
177 |
177 def transform_font(font: Font, transform: AffineTransform): Font = |
178 def transform_font(font: Font, transform: AffineTransform): Font = |
178 { |
179 { |
179 import scala.collection.JavaConversions._ |
180 import scala.collection.JavaConversions._ |