/// <summary> /// Sets the baseline of the words of the specified box to certain height /// </summary> /// <param name="g">Device info</param> /// <param name="b">box to check words</param> /// <param name="baseline">baseline</param> internal void SetBaseLine(RGraphics g, CssBox b, double baseline) { //TODO: Aqui me quede, checar poniendo "by the" con un font-size de 3em List <CssRect> ws = WordsOf(b); if (!Rectangles.ContainsKey(b)) { return; } RRect r = Rectangles[b]; //Save top of words related to the top of rectangle double gap = 0f; if (ws.Count > 0) { gap = ws[0].Top - r.Top; } else { CssRect firstw = b.FirstWordOccourence(b, this); if (firstw != null) { gap = firstw.Top - r.Top; } } //New top that words will have //float newtop = baseline - (Height - OwnerBox.FontDescent - 3); //OLD double newtop = baseline; // -GetBaseLineHeight(b, g); //OLD if (b.ParentBox != null && b.ParentBox.Rectangles.ContainsKey(this) && r.Height < b.ParentBox.Rectangles[this].Height) { //Do this only if rectangle is shorter than parent's double recttop = newtop - gap; RRect newr = new RRect(r.X, recttop, r.Width, r.Height); Rectangles[b] = newr; b.OffsetRectangle(this, gap); } foreach (var word in ws) { if (!word.IsImage) { word.Top = newtop; } } }
internal void SetBaseLine(Graphics g, CssBox b, float baseline) { List <CssBoxWord> cssBoxWords = this.WordsOf(b); if (!this.Rectangles.ContainsKey(b)) { return; } RectangleF item = this.Rectangles[b]; float top = 0f; if (cssBoxWords.Count <= 0) { CssBoxWord cssBoxWord = b.FirstWordOccourence(b, this); if (cssBoxWord != null) { top = cssBoxWord.Top - item.Top; } } else { top = cssBoxWords[0].Top - item.Top; } float single = baseline - this.GetBaseLineHeight(b, g); if (b.ParentBox != null && b.ParentBox.Rectangles.ContainsKey(this) && item.Height < b.ParentBox.Rectangles[this].Height) { float single1 = single - top; RectangleF rectangleF = new RectangleF(item.X, single1, item.Width, item.Height); this.Rectangles[b] = rectangleF; b.OffsetRectangle(this, top); } foreach (CssBoxWord cssBoxWord1 in cssBoxWords) { if (cssBoxWord1.IsImage) { continue; } cssBoxWord1.Top = single; } }