[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with a font
From: |
Thomas Morley |
Subject: |
Re: Problem with a font |
Date: |
Fri, 6 Apr 2018 11:41:41 +0200 |
Hi Walter,
2018-04-06 9:49 GMT+02:00 Walter Garcia-Fontes <address@hidden>:
> * Torsten Hämmerle, address@hidden [05/04/18 20:48]:
>> A missing bold font can be emulated by printing the stencil several times
>> (slightly shifted) - like in Don E. Knuth's "poor man's bold" (TeX).
>>
>> If you get stuck, don't hesitate to ask.
>
> OK, here is an ugly solution (font experts please look somewhere
> else):
I'm not a font expert ;)
However, I thought it might be nice to have commands to fake
text-appearance, if the font-to-use doesn't deliver what' needed.
We already have
smallCaps-markup
slanted-markup by Torsten
Below my approach for poor-mans-bold-markup and in combination with \slanted
It uses `stencil-whiteout-outline' which is already in 2.19, here
downgraded to make it work with 2.18.2
\version "2.18.2"
#(define*-public (stencil-whiteout-outline
stil #:optional (thickness 0.3) (color white)
(angle-increments 16) (radial-increments 1))
"This function works by creating a series of white or @var{color}
stencils radially offset from the original stencil with angles from
0 to 2*pi, at an increment of @code{angle-inc}, and with radii
from @code{radial-inc} to @var{thickness}. @var{thickness} is how big
the white outline is, as a multiple of line-thickness.
@var{radial-increments} is how many copies of the white stencil we make
on our way out to thickness. @var{angle-increments} is how many copies
of the white stencil we make between 0 and 2*pi."
(if (or (not (positive? angle-increments))
(not (positive? radial-increments)))
(begin
(ly:warning
"Both angle-increments and radial-increments must be positive numbers.")
stil)
(let* ((angle-inc (/ 360 angle-increments))
(radial-inc (/ thickness radial-increments)))
(define (circle-plot ang dec radius original-stil new-stil)
;; ang (angle) and dec (decrement) are in degrees, not radians
(if (<= ang 0)
new-stil
(circle-plot (- ang dec) dec radius original-stil
(ly:stencil-add
new-stil
(ly:stencil-translate original-stil
;(ly:directed ang radius)
;; 2.18.2:
(cons
(* radius (cos (degrees->radians ang)))
(* radius (sin (degrees->radians ang))))
)))))
(define (radial-plot radius original-stil new-stil)
(if (<= radius 0)
new-stil
(ly:stencil-add new-stil
(radial-plot
(- radius radial-inc)
original-stil
(circle-plot 360 angle-inc
radius original-stil empty-stencil)))))
(let ((whiteout-expr
(ly:stencil-expr
(stencil-with-color
(radial-plot thickness stil empty-stencil)
color))))
(ly:stencil-add
(ly:make-stencil
`(delay-stencil-evaluation ,(delay whiteout-expr)))
stil)))))
#(define-markup-command
(slanted layout props arg)
(markup?)
#:category font
#:properties ((slant-angle 12))
"Fake a slanted font"
(let* ((alpha-rad (* 0.5 (acos (tan (* (/ PI -180) slant-angle)))))
(alpha-deg (* (/ 180 PI) alpha-rad))
(stencil
(if (markup? arg)
(interpret-markup layout props arg)
empty-stencil))
(x-ext (ly:stencil-extent stencil X))
(y-ext (ly:stencil-extent stencil Y)))
(ly:make-stencil
(ly:stencil-expr
(ly:stencil-scale
(ly:stencil-rotate
(ly:stencil-scale
(ly:stencil-rotate
(ly:make-stencil
(ly:stencil-expr stencil)
(cons 0 0)
(cons 0 0))
45 0 0)
1
(* (tan alpha-rad)))
(* (- alpha-deg)) 0 0)
(* (sqrt 2) (cos alpha-rad)) (/ 0.5 (sqrt 0.5) (sin alpha-rad))))
x-ext
y-ext)))
#(define-markup-command (poor-mans-bold layout props arg)(markup?)
#:properties ((thickness 0.03)
(color black)
(angle-increments 4)
(radial-increments 1))
;; Currently the entire stencil of `arg' will be outlined.
;; TODO better results by splitting `arg' in characters, outlining them
;; and putting them together again?
;; -> smallCaps
(stencil-whiteout-outline
(interpret-markup layout props
arg)
thickness
color
angle-increments
radial-increments))
tst =
\markup
\override #'(font-name . "Escolar2")
%\override #'(font-name . "Purisa")
%\override #'(font-name . "Times New Roman,")
\wordwrap {
Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
}
\markup
\box
\tst
\markup
\box
\poor-mans-bold
\tst
\markup
\box
\slanted
\tst
\markup
\box
\poor-mans-bold
\slanted
\tst
Some ugliness is obvious, though ...
Cheers,
Harm
- Re: Problem with a font, (continued)
- Re: Problem with a font, Walter Garcia-Fontes, 2018/04/03
- Re: Problem with a font, Abraham Lee, 2018/04/03
- Re: Problem with a font, Walter Garcia-Fontes, 2018/04/03
- Re: Problem with a font, Thomas Morley, 2018/04/03
- Re: Problem with a font, Walter Garcia-Fontes, 2018/04/03
- Re: Problem with a font, Thomas Morley, 2018/04/03
- Re: Problem with a font, Torsten Hämmerle, 2018/04/05
- Re: Problem with a font, Walter Garcia-Fontes, 2018/04/05
- Re: Problem with a font, Torsten Hämmerle, 2018/04/05
- Re: Problem with a font, Walter Garcia-Fontes, 2018/04/06
- Re: Problem with a font,
Thomas Morley <=
- Re: Problem with a font, Malte Meyn, 2018/04/03
- Re: Problem with a font, Simon Albrecht, 2018/04/04
Re: Problem with a font, Andrew Bernard, 2018/04/05
- Re: Problem with a font, Walter Garcia-Fontes, 2018/04/06
- Re: Problem with a font, Simon Albrecht, 2018/04/06
- Re: Problem with a font, Andrew Bernard, 2018/04/06
- Re: Problem with a font, Walter Garcia-Fontes, 2018/04/06
- Re: Problem with a font, David Kastrup, 2018/04/06
- Re: Problem with a font, Torsten Hämmerle, 2018/04/06
Re: Problem with a font, Torsten Hämmerle, 2018/04/06