2004-12-13 Jan Nieuwenhuizen <janneke@gnu.org>
+ * scm/output-gnome.scm (text): Hello world, again.
+
+ * scm/output-svg.scm (named-glyph): New function. Hello world!
+
+ * lily/modified-font-metric.cc (index_to_charcode): New method.
+
* lily/include/font-metric.hh (index_to_charcode): New function.
* lily/font-metric.cc (ly:font-glyph-name-to-charcode): Use it in
new function.
(ly:font-glyph-to-index): Remove.
- * lily/font-metric.cc ("ly:font-glyph-name-to-charcode"): Bugfix:
- use original font.
-
2004-12-12 Han-Wen Nienhuys <hanwen@xs4all.nl>
* lily/open-type-font.cc (make_index_to_charcode_map): new method.
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "index");
- unsigned charcode;
- if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
- charcode = mfm->original_font ()->index_to_charcode (ly_scm2int (index));
- else
- charcode = fm->index_to_charcode (ly_scm2int (index));
-
- return scm_from_unsigned_integer (charcode);
+ return scm_from_unsigned_integer (fm->index_to_charcode (ly_scm2int (index)));
}
LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG2, __FUNCTION__, "string");
#if 1
- unsigned charcode;
- if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
- charcode = mfm->original_font ()->index_to_charcode (mfm->original_font ()->name_to_index (ly_scm2string (name)));
- else
- charcode = fm->index_to_charcode (fm->name_to_index (ly_scm2string (name)));
+ return scm_from_unsigned_integer (fm->index_to_charcode (fm->name_to_index (ly_scm2string (name))));
#else
- unsigned charcode;
- if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
- charcode = mfm->original_font ()->glyph_name_to_charcode (ly_scm2string (name));
- else
- charcode = fm->glyph_name_to_charcode (ly_scm2string (name));
+ return scm_from_unsigned_integer (fm->glyph_name_to_charcode (ly_scm2string (name)));
#endif
-
- return scm_from_unsigned_integer (charcode);
}
LY_DEFINE (ly_text_dimension,"ly:text-dimension",
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
-
if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
return ly_font_name (mfm->original_font ()->self_scm ());
else if (Adobe_font_metric* afm = dynamic_cast<Adobe_font_metric*> (fm))
return SCM_BOOL_F;
}
-
-
LY_DEFINE (ly_font_magnification,"ly:font-magnification", 1 , 0, 0,
(SCM font),
"Given the font metric @var{font}, return the "
virtual Offset get_indexed_wxwy (int) const;
virtual Offset attachment_point (String) const;
virtual int name_to_index (String) const;
+ virtual unsigned index_to_charcode (int) const;
virtual String coding_scheme () const;
virtual Font_metric *original_font () const;
return orig_->name_to_index (s);
}
+unsigned
+Modified_font_metric::index_to_charcode (int i) const
+{
+ return orig_->index_to_charcode (i);
+}
+
int
Modified_font_metric::index_to_ascii (int k) const
{
(define-public (char->unicode-index font char)
(ly:font-index-to-charcode font (char->integer char)))
+
+(define-public (otf-name-mangling font family)
+ ;; Hmm, family is bigcheese20/26?
+ (if (string=? (substring family 0 (min (string-length family) 9))
+ "bigcheese")
+ "LilyPond"
+ family))
+
;;; - lilylib.
;;; * Release schedule and packaging of dependencies. This hack
;;; depends on several CVS and TLA development sources. In the works.
-;;; * Maybe we need to have a unicode mapping somehow, we could
-;;; - use OpenType instead of Type1
-;;; http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00098.html
-;;; - or fix the pangofc-afm-decoder and add it to Pango (no chance?)
-;;; or have fontconfig read AFM files
-;;; http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00103.html
;;; You need:
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; globals
-;; junkme
-(define system-origin '(0 . 0))
-
;;; set by framework-gnome.scm
(define canvas-root #f)
(define output-scale #f)
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helper functions
(force-output (current-error-port)))
(define (debugf string . rest)
- (if #t
+ (if #f
(apply stderr (cons string rest))))
+(define (list->offsets accum coords)
+ (if (null? coords)
+ accum
+ (cons (cons (car coords) (cadr coords))
+ (list->offsets accum (cddr coords)))))
+
(define (utf8 i)
(cond
((< i #x80) (list (integer->char i)))
string-append
(map (lambda (x) (char->utf8-string font x)) (string->list string))))
+(define (music-font? font)
+ (let ((encoding (ly:font-encoding font))
+ (family (font-family font)))
+ (or (memq encoding '(fetaMusic fetaBraces))
+ (string=? (substring family 0 (min (string-length family) 9))
+ "bigcheese"))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; stencil outputters
;;;
bezier))
(define (char font i)
- (text font (integer->char i)))
+ (text font (ly:font-index-to-charcode (integer->char i))))
;; FIXME: naming
(define (filledbox breapth width depth height)
;; FIXME ugly hack to skip #unspecified ...
(if (and item (not (eq? item (if #f #f))))
(begin
- (move item
- (* output-scale (+ (car system-origin) x))
- (* output-scale (- (car system-origin) y)))
+ (move item (* output-scale x) (* output-scale (- y)))
(affine-relative item output-scale 0 0 output-scale 0 0)
item)
#f)))
(set-path-def props def)
props))
-(define (list->offsets accum coords)
- (if (null? coords)
- accum
- (cons (cons (car coords) (cadr coords))
- (list->offsets accum (cddr coords)))))
-
(define (named-glyph font name)
- (debugf "glyph:~S\n" name)
- (debugf "index:~S\n" (ly:font-glyph-name-to-charcode font name))
- (debugf "font:~S\n" (font-family font))
(text font (ly:font-glyph-name-to-charcode font name)))
(define (polygon coords blotdiameter)
#:join-style 'round)))
(define (text font s)
+
(define (pango-font-name font)
(stderr "FONT-NAME:~S:~S\n" (ly:font-name font) (ly:font-design-size font))
-
- (let ((family (font-family font)))
- ;; Hmm, family is bigcheese20?
- (if (string=? (substring family 0 (min (string-length family) 9))
- "bigcheese")
- (begin
- ;; FIXME: FONT-NAME:#f:8.85678704856787
- ;;(format #f "~S, ~S" (ly:font-name font) (ly:font-design-size font))
- (stderr "BIGCHEESE\n")
- "LilyPond 20"
- )
- family)))
-
+ (otf-name-mangling font (font-family font)))
+
(define (pango-font-size font)
(let* ((designsize (ly:font-design-size font))
(magnification (* (ly:font-magnification font)))
scaling))
- (let ((encoding (ly:font-encoding font)))
- (make <gnome-canvas-text>
- #:parent (canvas-root)
- ;; ugh, experimental placement corections
- ;; #:x 0.0 #:y 0.0
- #:x 0.0 #:y (if (memq encoding '(fetaMusic fetaBraces)) 0.15 0.69)
- #:anchor (if (memq encoding '(fetaMusic fetaBraces)) 'west 'south-west)
- #:font (pango-font-name font)
- #:size-points (pango-font-size font)
- #:size-set #t
- #:text (if (char? s)
- (char->utf8-string font s)
- (if (integer? s)
- (integer->utf8-string font s)
- (string->utf8-string font s))))))
+ (make <gnome-canvas-text>
+ #:parent (canvas-root)
+ ;; ugh, experimental placement corections
+ ;; #:x 0.0 #:y 0.0
+ #:x 0.0 #:y (if (music-font? font) 0.15 0.69)
+ #:anchor (if (music-font? font) 'west 'south-west)
+ #:font (pango-font-name font)
+ #:size-points (pango-font-size font)
+ #:size-set #t
+ #:text (if (integer? s)
+ (integer->utf8-string font s)
+ (string->utf8-string font s))))
;;;; http://www.w3.org/TR/SVG11
-;;; FIXME
-
-;;; * sodipodi gets confuseed by dashes in font names.
-;;;
-;;; removing feta-nummer*.pfa (LilyPond-feta-nummer),
-;;; feta-braces*.pfa (LilyPond-feta-braces), feta-din*.pfa
-;;; (LilyPond-feta-din) from font path shows feta fonts in sodipodi.
-;;;
-;;; * inkscape fails to map Feta fonts to private use area (PUA) E000
-;;; (sodipodi is fine).
-
-;;; * maybe we need to have a unicode mapping somehow, we could
-;;; - use OpenType instead of Type1
-;;; http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00098.html
-;;;
-;;; - or fix the pangofc-afm-decoder and add it to Pango (no chance?)
-;;; or have fontconfig read AFM files
-;;; http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00103.html
-
-
(debug-enable 'backtrace)
(define-module (scm output-svg))
(define this-module (current-module))
(if #f
(apply stderr (cons string rest))))
-
(define (dispatch expr)
(let ((keyword (car expr)))
(cond
(debugf "design:~S\n" designsize)
scaling))
+(define (integer->entity integer)
+ (format #f "&#x~x;" integer))
+
(define (char->entity font char)
- (format #f "&#x~x;" (char->unicode-index font char)))
+ (integer->entity (char->unicode-index font char)))
(define (string->entities font string)
(apply string-append
(let* ((encoding (ly:font-encoding font))
(anchor (if (memq encoding '(fetaMusic fetaBraces)) 'start 'start)))
(format #f "font-family:~a;font-size:~a;text-anchor:~S;"
- (font-family font) (font-size font) anchor)))
+ (otf-name-mangling font (font-family font))
+ (font-size font) anchor)))
(define (fontify font expr)
(tagify "text" expr (cons 'style (svg-font font))))
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; stencil outputters
;;;
(define (filledbox breapth width depth height)
(round-filled-box breapth width depth height 0))
+(define (named-glyph font name)
+ (dispatch
+ `(fontify ,font ,(tagify "tspan"
+ (integer->entity
+ (ly:font-glyph-name-to-charcode font name))))))
+
(define (placebox x y expr)
(tagify "g"
;; FIXME -- JCN