public static IFragment[] LayoutRubyInLine(IFragment[] fragmentList, float endSpaceLength) { IFragment[] layouted = new IFragment[fragmentList.Length]; var n = fragmentList.Length; for (int i = 0; i < n; ++i) { IFragment current = fragmentList[i]; IAdjacentableToFragment before = (i > 0 ? fragmentList[i - 1] : DenyRubyHanging.theInstance); IAdjacentableToFragment after = (i < n - 1 ? fragmentList[i + 1] : DenyRubyHanging.theInstance); layouted[i] = current.LayoutRuby(before, after); } return(layouted); }
private static IFragment[] LayoutRubyInLine( LineBreaking.ILineConstraint constraint, IFragment[] fragmentList, float endSpaceLength) { //TODO: constraint を考慮して最適なものを選ぶ IFragment[] layouted = new IFragment[fragmentList.Length]; var n = fragmentList.Length; for (int i = 0; i < n; ++i) { IFragment current = fragmentList[i]; IAdjacentableToFragment before = (i > 0 ? fragmentList[i - 1] : DenyRubyHanging.theInstance); IAdjacentableToFragment after = (i < n - 1 ? fragmentList[i + 1] : DenyRubyHanging.theInstance); layouted[i] = current.LayoutRuby(before, after); } return(layouted); }
public override IFragment LayoutRuby(IAdjacentableToFragment before, IAdjacentableToFragment after) { var baseBasic = (BasicFragmentString)_baseFragments; var rubyBasic = (BasicFragmentString)_rubyFragments; float beforeAcceptance = before.RubyHangingAcceptanceAfter; float afterAcceptance = after.RubyHangingAcceptanceBefore; //NOTE: 中。肩付きは未対応 //TODO: 同じ文字に前後両方からかかった場合のアキ(処理のレベルを上げる必要!) float overLength = (float)( (rubyBasic.Length - rubyBasic.FirstOffset) - (baseBasic.Length - baseBasic.FirstOffset)); float alignment = (float)(baseBasic.FirstOffset - rubyBasic.FirstOffset); if (overLength > 0) { var halfOverLength = overLength / 2; if (beforeAcceptance >= halfOverLength && afterAcceptance >= halfOverLength) { //前後ともに掛け return(new LayoutedRubyFragment(baseBasic, rubyBasic.Offset(alignment - halfOverLength))); } else if (afterAcceptance >= halfOverLength) { //前にアキ、後ろは掛け var layoutedBase = baseBasic.Offset(halfOverLength); return(new LayoutedRubyFragment(layoutedBase, rubyBasic.Offset(alignment))); } else { //TODO: 前のみ掛け。ただし後ろのみ掛けより優先順位は下。実装は構造変更が必要(最後の letter の length 伸ばす) //それ以外は内部にアキ。 //今のところ掛けかつアキはしていない。 var layoutedBase = baseBasic.InsertSpaceInside(overLength); return(new LayoutedRubyFragment(layoutedBase, rubyBasic.Offset(alignment))); } } else { var alignedRuby = rubyBasic.Offset(alignment); return(new LayoutedRubyFragment(baseBasic, alignedRuby.InsertSpace(-overLength))); } }
IFragment IFragment.LayoutRuby(IAdjacentableToFragment before, IAdjacentableToFragment after) { return(this); }
public override IFragment LayoutRuby(IAdjacentableToFragment before, IAdjacentableToFragment after) { throw new InvalidOperationException("This has already been layouted!"); }
public abstract IFragment LayoutRuby(IAdjacentableToFragment before, IAdjacentableToFragment after);
public override IFragment LayoutRuby(IAdjacentableToFragment before, IAdjacentableToFragment after) { return(this); }