OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
3 * Copyright (c) 2014 BlackBerry Limited. All rights reserved. | 3 * Copyright (c) 2014 BlackBerry Limited. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 static hb_position_t harfBuzzGetGlyphHorizontalKerning(hb_font_t*, void* fontDat
a, hb_codepoint_t leftGlyph, hb_codepoint_t rightGlyph, void*) | 121 static hb_position_t harfBuzzGetGlyphHorizontalKerning(hb_font_t*, void* fontDat
a, hb_codepoint_t leftGlyph, hb_codepoint_t rightGlyph, void*) |
122 { | 122 { |
123 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; | 123 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; |
124 if (hbFontData->m_paint.isVerticalText()) { | 124 if (hbFontData->m_paint.isVerticalText()) { |
125 // We don't support cross-stream kerning | 125 // We don't support cross-stream kerning |
126 return 0; | 126 return 0; |
127 } | 127 } |
128 | 128 |
129 SkTypeface* typeface = hbFontData->m_paint.getTypeface(); | 129 SkTypeface* typeface = hbFontData->m_paint.getTypeface(); |
130 | 130 |
131 const uint16_t glyphs[2] = { leftGlyph, rightGlyph }; | 131 const uint16_t glyphs[2] = { static_cast<uint16_t>(leftGlyph), static_cast<u
int16_t>(rightGlyph) }; |
132 int32_t kerningAdjustments[1] = { 0 }; | 132 int32_t kerningAdjustments[1] = { 0 }; |
133 | 133 |
134 if (typeface->getKerningPairAdjustments(glyphs, 2, kerningAdjustments)) { | 134 if (typeface->getKerningPairAdjustments(glyphs, 2, kerningAdjustments)) { |
135 SkScalar upm = SkIntToScalar(typeface->getUnitsPerEm()); | 135 SkScalar upm = SkIntToScalar(typeface->getUnitsPerEm()); |
136 SkScalar size = hbFontData->m_paint.getTextSize(); | 136 SkScalar size = hbFontData->m_paint.getTextSize(); |
137 return SkiaScalarToHarfBuzzPosition(SkScalarMulDiv(SkIntToScalar(kerning
Adjustments[0]), size, upm)); | 137 return SkiaScalarToHarfBuzzPosition(SkScalarMulDiv(SkIntToScalar(kerning
Adjustments[0]), size, upm)); |
138 } | 138 } |
139 | 139 |
140 return 0; | 140 return 0; |
141 } | 141 } |
142 | 142 |
143 static hb_position_t harfBuzzGetGlyphVerticalKerning(hb_font_t*, void* fontData,
hb_codepoint_t topGlyph, hb_codepoint_t bottomGlyph, void*) | 143 static hb_position_t harfBuzzGetGlyphVerticalKerning(hb_font_t*, void* fontData,
hb_codepoint_t topGlyph, hb_codepoint_t bottomGlyph, void*) |
144 { | 144 { |
145 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; | 145 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; |
146 if (!hbFontData->m_paint.isVerticalText()) { | 146 if (!hbFontData->m_paint.isVerticalText()) { |
147 // We don't support cross-stream kerning | 147 // We don't support cross-stream kerning |
148 return 0; | 148 return 0; |
149 } | 149 } |
150 | 150 |
151 SkTypeface* typeface = hbFontData->m_paint.getTypeface(); | 151 SkTypeface* typeface = hbFontData->m_paint.getTypeface(); |
152 | 152 |
153 const uint16_t glyphs[2] = { topGlyph, bottomGlyph }; | 153 const uint16_t glyphs[2] = { static_cast<uint16_t>(topGlyph), static_cast<ui
nt16_t>(bottomGlyph) }; |
154 int32_t kerningAdjustments[1] = { 0 }; | 154 int32_t kerningAdjustments[1] = { 0 }; |
155 | 155 |
156 if (typeface->getKerningPairAdjustments(glyphs, 2, kerningAdjustments)) { | 156 if (typeface->getKerningPairAdjustments(glyphs, 2, kerningAdjustments)) { |
157 SkScalar upm = SkIntToScalar(typeface->getUnitsPerEm()); | 157 SkScalar upm = SkIntToScalar(typeface->getUnitsPerEm()); |
158 SkScalar size = hbFontData->m_paint.getTextSize(); | 158 SkScalar size = hbFontData->m_paint.getTextSize(); |
159 return SkiaScalarToHarfBuzzPosition(SkScalarMulDiv(SkIntToScalar(kerning
Adjustments[0]), size, upm)); | 159 return SkiaScalarToHarfBuzzPosition(SkScalarMulDiv(SkIntToScalar(kerning
Adjustments[0]), size, upm)); |
160 } | 160 } |
161 | 161 |
162 return 0; | 162 return 0; |
163 } | 163 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 hb_font_make_immutable(font); | 234 hb_font_make_immutable(font); |
235 return font; | 235 return font; |
236 } | 236 } |
237 | 237 |
238 GlyphBufferAdvance HarfBuzzShaper::createGlyphBufferAdvance(float width, float h
eight) | 238 GlyphBufferAdvance HarfBuzzShaper::createGlyphBufferAdvance(float width, float h
eight) |
239 { | 239 { |
240 return GlyphBufferAdvance(width, height); | 240 return GlyphBufferAdvance(width, height); |
241 } | 241 } |
242 | 242 |
243 } // namespace WebCore | 243 } // namespace WebCore |
OLD | NEW |