 Chromium Code Reviews
 Chromium Code Reviews Issue 1740163002:
  Improve horizontal baseline detection.  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master
    
  
    Issue 1740163002:
  Improve horizontal baseline detection.  (Closed) 
  Base URL: https://skia.googlesource.com/skia.git@master| OLD | NEW | 
|---|---|
| 1 | 1 | 
| 2 /* | 2 /* | 
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project | 
| 4 * | 4 * | 
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be | 
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. | 
| 7 */ | 7 */ | 
| 8 | 8 | 
| 9 | 9 | 
| 10 #include "SkScalerContext.h" | 10 #include "SkScalerContext.h" | 
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 820 } | 820 } | 
| 821 | 821 | 
| 822 // The 'remainingWithoutRotation' matrix GsA is the non-rotational part of A without the scale. | 822 // The 'remainingWithoutRotation' matrix GsA is the non-rotational part of A without the scale. | 
| 823 if (GsA) { | 823 if (GsA) { | 
| 824 *GsA = GA; | 824 *GsA = GA; | 
| 825 // G is rotational so reorders with the scale. | 825 // G is rotational so reorders with the scale. | 
| 826 GsA->preScale(SkScalarInvert(s->fX), SkScalarInvert(s->fY)); | 826 GsA->preScale(SkScalarInvert(s->fX), SkScalarInvert(s->fY)); | 
| 827 } | 827 } | 
| 828 } | 828 } | 
| 829 | 829 | 
| 830 SkAxisAlignment SkComputeAxisAlignmentForHText(const SkMatrix& matrix) { | 830 SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText() { | 
| 831 SkASSERT(!matrix.hasPerspective()); | 831 // Why fPost2x2 can be used here. | 
| 832 // getSingleMatrix multiplies in getLocalMatrix, which consists of | |
| 833 // * fTextSize (a scale, which has no effect) | |
| 834 // * fPreScaleX (a scale in x, which has no effect) | |
| 835 // * fPreSkewX (has no effect, but would on vertical text alignment). | |
| 836 // In other words, making the text bigger, stretching it along the | |
| 837 // horizontal axis, or fake italicizing it does not move the baseline. | |
| 
herb_g
2016/02/29 18:37:10
italicizing; it does...
 
bungeman-skia
2016/02/29 19:21:20
it actually has no effect on the horizontal baseli
 | |
| 832 | 838 | 
| 833 if (0 == matrix[SkMatrix::kMSkewY]) { | 839 if (0 == fRec.fPost2x2[1][0]) { | 
| 840 // The x axis is mapped onto the x axis. | |
| 834 return kX_SkAxisAlignment; | 841 return kX_SkAxisAlignment; | 
| 835 } | 842 } | 
| 836 if (0 == matrix[SkMatrix::kMSkewX]) { | 843 if (0 == fRec.fPost2x2[0][0]) { | 
| 844 // The x axis is mapped onto the y axis. | |
| 837 return kY_SkAxisAlignment; | 845 return kY_SkAxisAlignment; | 
| 838 } | 846 } | 
| 839 return kNone_SkAxisAlignment; | 847 return kNone_SkAxisAlignment; | 
| 840 } | 848 } | 
| 841 | 849 | 
| 842 /////////////////////////////////////////////////////////////////////////////// | 850 /////////////////////////////////////////////////////////////////////////////// | 
| 843 | 851 | 
| 844 class SkScalerContext_Empty : public SkScalerContext { | 852 class SkScalerContext_Empty : public SkScalerContext { | 
| 845 public: | 853 public: | 
| 846 SkScalerContext_Empty(SkTypeface* face, const SkDescriptor* desc) | 854 SkScalerContext_Empty(SkTypeface* face, const SkDescriptor* desc) | 
| (...skipping 25 matching lines...) Expand all Loading... | |
| 872 | 880 | 
| 873 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, | 881 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, | 
| 874 bool allowFailure) const { | 882 bool allowFailure) const { | 
| 875 SkScalerContext* c = this->onCreateScalerContext(desc); | 883 SkScalerContext* c = this->onCreateScalerContext(desc); | 
| 876 | 884 | 
| 877 if (!c && !allowFailure) { | 885 if (!c && !allowFailure) { | 
| 878 c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), desc); | 886 c = new SkScalerContext_Empty(const_cast<SkTypeface*>(this), desc); | 
| 879 } | 887 } | 
| 880 return c; | 888 return c; | 
| 881 } | 889 } | 
| OLD | NEW |