OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 *width = SkiaScalarToHarfBuzzPosition(skWidth); | 150 *width = SkiaScalarToHarfBuzzPosition(skWidth); |
151 if (extents) { | 151 if (extents) { |
152 // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to
be y-grows-up. | 152 // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to
be y-grows-up. |
153 extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); | 153 extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); |
154 extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); | 154 extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); |
155 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); | 155 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); |
156 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); | 156 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
| 160 #if !defined(HB_VERSION_ATLEAST) |
| 161 #define HB_VERSION_ATLEAST(major, minor, micro) 0 |
| 162 #endif |
| 163 |
160 static hb_bool_t harfBuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin
t_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* user
Data) | 164 static hb_bool_t harfBuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin
t_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* user
Data) |
161 { | 165 { |
162 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; | 166 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; |
163 | 167 |
164 if (variationSelector) { | 168 if (variationSelector) { |
165 #if OS(LINUX) | 169 #if !HB_VERSION_ATLEAST(0, 9, 28) |
166 // TODO(kojii): Linux non-official builds cannot use new HB APIs | |
167 // until crbug.com/462689 resolved or pangoft2 updates its HB. | |
168 return false; | 170 return false; |
169 #else | 171 #else |
170 // Skia does not support variation selectors, but hb does. | 172 // Skia does not support variation selectors, but hb does. |
171 // We're not fully ready to switch to hb-ot-font yet, | 173 // We're not fully ready to switch to hb-ot-font yet, |
172 // but are good enough to get glyph IDs for OpenType fonts. | 174 // but are good enough to get glyph IDs for OpenType fonts. |
173 if (!hbFontData->m_hbOpenTypeFont) { | 175 if (!hbFontData->m_hbOpenTypeFont) { |
174 hbFontData->m_hbOpenTypeFont = hb_font_create(hbFontData->m_face); | 176 hbFontData->m_hbOpenTypeFont = hb_font_create(hbFontData->m_face); |
175 hb_ot_font_set_funcs(hbFontData->m_hbOpenTypeFont); | 177 hb_ot_font_set_funcs(hbFontData->m_hbOpenTypeFont); |
176 } | 178 } |
177 return hb_font_get_glyph(hbFontData->m_hbOpenTypeFont, unicode, variatio
nSelector, glyph); | 179 return hb_font_get_glyph(hbFontData->m_hbOpenTypeFont, unicode, variatio
nSelector, glyph); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 hb_font_t* font = hb_font_create(m_face); | 337 hb_font_t* font = hb_font_create(m_face); |
336 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB
uzzFontData); | 338 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB
uzzFontData); |
337 float size = m_platformData->size(); | 339 float size = m_platformData->size(); |
338 int scale = SkiaScalarToHarfBuzzPosition(size); | 340 int scale = SkiaScalarToHarfBuzzPosition(size); |
339 hb_font_set_scale(font, scale, scale); | 341 hb_font_set_scale(font, scale, scale); |
340 hb_font_make_immutable(font); | 342 hb_font_make_immutable(font); |
341 return font; | 343 return font; |
342 } | 344 } |
343 | 345 |
344 } // namespace blink | 346 } // namespace blink |
OLD | NEW |