コード例 #1
0
ファイル: SvgPage.cs プロジェクト: notator/Moritz
        /// <summary>
        /// The systems contain Metrics info, but their top staffline is at 0.
        /// The systems are moved to their correct vertical positions on the page here.
        /// If pageNumber is set to 0, all the systems in pageSystems will be printed
        /// in a single .svg file, whose page height has been changed accordingly.
        /// </summary>
        /// <param name="Systems"></param>
        public SvgPage(SvgScore containerScore, PageFormat pageFormat, int pageNumber, TextInfo infoTextInfo, List<SvgSystem> pageSystems, bool lastPage)
        {
            _score = containerScore;
            _pageFormat = pageFormat;
            _pageNumber = pageNumber;
            _infoTextInfo = infoTextInfo;

            Systems = pageSystems;

            if(pageNumber == 0)
            {
                pageFormat.BottomVBPX = GetNewBottomVBPX(pageSystems);
                pageFormat.BottomMarginPos = (int) (pageFormat.BottomVBPX - pageFormat.DefaultDistanceBetweenSystems);
            }

            MoveSystemsVertically(pageFormat, pageSystems, (pageNumber == 1 || pageNumber == 0), lastPage);
        }
コード例 #2
0
ファイル: SvgWriter.cs プロジェクト: suvjunmd/Moritz
 public void SvgText(string id, TextInfo textInfo, float x, float y)
 {
     _w.WriteStartElement("text");
     if(!String.IsNullOrEmpty(id))
     {
         _w.WriteAttributeString("id", id);
     }
     _w.WriteAttributeString("x", x.ToString(M.En_USNumberFormat));
     _w.WriteAttributeString("y", y.ToString(M.En_USNumberFormat));
     switch(textInfo.TextHorizAlign)
     {
         case TextHorizAlign.left:
             break;
         case TextHorizAlign.center:
             _w.WriteAttributeString("text-anchor", "middle");
             break;
         case TextHorizAlign.right:
             _w.WriteAttributeString("text-anchor", "end");
             break;
     }
     _w.WriteAttributeString("font-size", textInfo.FontHeight.ToString(M.En_USNumberFormat));
     _w.WriteAttributeString("font-family", textInfo.FontFamily);
     if(textInfo.ColorString != null
         && !String.IsNullOrEmpty(textInfo.ColorString.String)
         && !textInfo.ColorString.IsBlack)
         _w.WriteAttributeString("fill", textInfo.ColorString.String);
     _w.WriteString(textInfo.Text);
     _w.WriteEndElement(); // text
 }
コード例 #3
0
ファイル: SvgPage.cs プロジェクト: notator/Moritz
        /// <summary>
        /// Adds the link, main title and the author to the first page.
        /// </summary>
        protected void WritePage1TitleAndAuthor(SvgWriter w, Metadata metadata)
        {
            string titlesFontFamily = "Open Sans";

            TextInfo titleInfo =
                new TextInfo(metadata.MainTitle, titlesFontFamily, _pageFormat.Page1TitleHeight,
                    null, TextHorizAlign.center);
            TextInfo authorInfo =
              new TextInfo(metadata.Author, titlesFontFamily, _pageFormat.Page1AuthorHeight,
                  null, TextHorizAlign.right);
            w.WriteStartElement("g");
            w.WriteAttributeString("id", "titles");
            w.SvgText("mainTitle", titleInfo, _pageFormat.Right / 2F, _pageFormat.Page1TitleY);
            w.SvgText("author", authorInfo, _pageFormat.RightMarginPos, _pageFormat.Page1TitleY);
            w.WriteEndElement(); // group
        }
コード例 #4
0
ファイル: Metrics.cs プロジェクト: notator/Moritz
        /// <summary>
        /// clichtDynamics: { "Ø", "∏", "π", "p", "P", "F", "f", "ƒ", "Ï", "Î" };
        ///                  pppp, ppp,  pp,  p,   mp,  mf,  f,   ff, fff, ffff
        /// </summary>
        /// <param name="gap"></param>
        /// <param name="textInfo"></param>
        /// <param name="isBelow"></param>
        /// <param name="topBoundary"></param>
        /// <param name="bottomBoundary"></param>
        public DynamicMetrics(float gap, TextInfo textInfo, bool isBelow)
            : base(textInfo.Text, true, textInfo.FontHeight, TextHorizAlign.left)
        {
            // visually centre the "italic" dynamic characters
            if(textInfo.Text == "p" || textInfo.Text == "f") // p, f
            {
                Move(textInfo.FontHeight * 0.02F, 0F);
            }
            else if(textInfo.Text == "F") // mf
            {
                Move(textInfo.FontHeight * 0.1F, 0F);
            }
            else
            {
                Move(textInfo.FontHeight * 0.05F, 0F);
            }
            float dynamicWidth = Right - Left;
            float moveLeftDelta = -(dynamicWidth / 2F) - (0.25F * gap); // "centre" italics
            Move(moveLeftDelta, 0F);

            IsBelow = isBelow;
        }
コード例 #5
0
ファイル: DrawObjects.cs プロジェクト: notator/Moritz
 public Text(object container, string text, string fontName, float fontHeight, TextHorizAlign align)
     : base(container)
 {
     _textInfo = new TextInfo(text, fontName, fontHeight, align);
 }
コード例 #6
0
ファイル: Metrics.cs プロジェクト: notator/Moritz
 public BarnumberMetrics(Graphics graphics, string ID_Type, TextInfo textInfo, FrameInfo frameInfo)
     : base(graphics, ID_Type, textInfo)
 {
     TextMetrics textMetrics = new TextMetrics(graphics, null, textInfo);
     _top = textMetrics.Top - frameInfo.PaddingY;
     _right = textMetrics.Right + frameInfo.PaddingX;
     _bottom = textMetrics.Bottom + frameInfo.PaddingY;
     _left = textMetrics.Left - frameInfo.PaddingX;
     _strokeWidth = frameInfo.StrokeWidth;
 }
コード例 #7
0
ファイル: Metrics.cs プロジェクト: notator/Moritz
        /// <summary>
        /// Sets the default Top, Right, Bottom, Left.
        ///   1. the width of the text is set to the value returned by MeasureText() (no padding)
        ///   2. the top and bottom metrics are set to values measured experimentally, using my
        ///   program: "../_demo projects/MeasureTextDemo/MeasureTextDemo.sln"
        ///		 _top is usually set here to the difference between the top and bottom line positions in that program
        ///		 _bottom is always set here to 0
        ///		 The fonts currently supported are:
        ///         "Open Sans"
        ///         "Open Sans Condensed"
        ///         "Arial"
        ///      These fonts have to be added to the Assistant Performer's fonts folder, and to its fontStyleSheet.css
        ///      so that they will work on any operating system.
        ///   3. moves the Metrics horizontally to take account of the textinfo.TextHorizAlign setting,
        ///      leaving OriginX and OriginY at 0F.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="textInfo"></param>
        private void SetDefaultMetrics(Graphics graphics, TextInfo textInfo)
        {
            //float maxFontSize = System.Single.MaxValue - 10F;
            float maxFontSize = 1000F;
            Size textMaxSize = new Size();
            try
            {
                textMaxSize = MeasureText(graphics, textInfo.Text, textInfo.FontFamily, maxFontSize);
            }
            catch(Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
            _left = 0;
            _right = textInfo.FontHeight * textMaxSize.Width / maxFontSize;
            switch(textInfo.FontFamily)
            {
                case "Open Sans": // titles
                case "Open Sans Condensed": // ornaments
                    _top = textInfo.FontHeight * -0.699F; // The difference between the height
                    _bottom = 0F;
                    break;
                case "Arial": // date stamp, lyrics, staff names
                    //_top = textInfo.FontHeight * -0.818F; // using MeasureTextDemo
                    _top = textInfo.FontHeight * -0.71F; // by experiment!
                    _bottom = 0F;
                    break;
                //case "Times New Roman": // staff names
                //	_top = textInfo.FontHeight * -1.12F;
                //	_bottom = 0F;
                //	break;
                default:
                    Debug.Assert(false, "Unknown font");
                    break;
            }

            if(textInfo.TextHorizAlign == TextHorizAlign.center)
                Move(-(_right / 2F), 0F);
            else if(textInfo.TextHorizAlign == TextHorizAlign.right)
                Move(-_right, 0F);

            _originX = 0;
            _originY = 0; // SVG originY is the baseline of the text
        }
コード例 #8
0
ファイル: Metrics.cs プロジェクト: notator/Moritz
 public TextMetrics(Graphics graphics, string type, TextInfo textInfo)
     : base(type, 0F, 0F)
 {
     SetDefaultMetrics(graphics, textInfo);
     _textInfo = textInfo;
 }
コード例 #9
0
ファイル: Metrics.cs プロジェクト: notator/Moritz
 public OrnamentMetrics(float gap, Graphics graphics, TextInfo textInfo, bool isBelow)
     : base(graphics, null, textInfo)
 {
     IsBelow = isBelow;
 }
コード例 #10
0
ファイル: Metrics.cs プロジェクト: notator/Moritz
        public LyricMetrics(float gap, Graphics graphics, TextInfo textInfo, bool isBelow)
            : base(graphics, null, textInfo)
        {
            float width = _right - _left;
            float newWidth = width * 0.75F;
            float widthMargin = (width - newWidth) / 2.0F;
            _left += widthMargin;
            _right -= widthMargin;

            IsBelow = isBelow;
        }