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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); | 186 extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); |
187 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); | 187 extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 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) | 191 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) |
192 { | 192 { |
193 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; | 193 HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData)
; |
194 | 194 |
195 if (variationSelector) { | 195 if (variationSelector) { |
| 196 #if OS(LINUX) |
| 197 // TODO(kojii): Linux non-official builds cannot use new HB APIs |
| 198 // until crbug.com/462689 resolved or pangoft2 updates its HB. |
| 199 return false; |
| 200 #else |
196 // Skia does not support variation selectors, but hb does. | 201 // Skia does not support variation selectors, but hb does. |
197 // We're not fully ready to switch to hb-ot-font yet, | 202 // We're not fully ready to switch to hb-ot-font yet, |
198 // but are good enough to get glyph IDs for OpenType fonts. | 203 // but are good enough to get glyph IDs for OpenType fonts. |
199 if (!hbFontData->m_hbOpenTypeFont) { | 204 if (!hbFontData->m_hbOpenTypeFont) { |
200 hbFontData->m_hbOpenTypeFont = hb_font_create(hbFontData->m_face); | 205 hbFontData->m_hbOpenTypeFont = hb_font_create(hbFontData->m_face); |
201 hb_ot_font_set_funcs(hbFontData->m_hbOpenTypeFont); | 206 hb_ot_font_set_funcs(hbFontData->m_hbOpenTypeFont); |
202 } | 207 } |
203 return hb_font_get_glyph(hbFontData->m_hbOpenTypeFont, unicode, variatio
nSelector, glyph); | 208 return hb_font_get_glyph(hbFontData->m_hbOpenTypeFont, unicode, variatio
nSelector, glyph); |
204 // When not found, glyph_func should return false rather than fallback t
o the base. | 209 // When not found, glyph_func should return false rather than fallback t
o the base. |
205 // http://lists.freedesktop.org/archives/harfbuzz/2015-May/004888.html | 210 // http://lists.freedesktop.org/archives/harfbuzz/2015-May/004888.html |
| 211 #endif |
206 } | 212 } |
207 | 213 |
208 WTF::HashMap<uint32_t, uint16_t>::AddResult result = hbFontData->m_glyphCach
eForFaceCacheEntry->add(unicode, 0); | 214 WTF::HashMap<uint32_t, uint16_t>::AddResult result = hbFontData->m_glyphCach
eForFaceCacheEntry->add(unicode, 0); |
209 if (result.isNewEntry) { | 215 if (result.isNewEntry) { |
210 SkPaint* paint = &hbFontData->m_paint; | 216 SkPaint* paint = &hbFontData->m_paint; |
211 paint->setTextEncoding(SkPaint::kUTF32_TextEncoding); | 217 paint->setTextEncoding(SkPaint::kUTF32_TextEncoding); |
212 uint16_t glyph16; | 218 uint16_t glyph16; |
213 paint->textToGlyphs(&unicode, sizeof(hb_codepoint_t), &glyph16); | 219 paint->textToGlyphs(&unicode, sizeof(hb_codepoint_t), &glyph16); |
214 result.storedValue->value = glyph16; | 220 result.storedValue->value = glyph16; |
215 *glyph = glyph16; | 221 *glyph = glyph16; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 hb_font_t* font = hb_font_create(m_face); | 366 hb_font_t* font = hb_font_create(m_face); |
361 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB
uzzFontData); | 367 hb_font_set_funcs(font, harfBuzzSkiaGetFontFuncs(), hbFontData, destroyHarfB
uzzFontData); |
362 float size = m_platformData->size(); | 368 float size = m_platformData->size(); |
363 int scale = SkiaScalarToHarfBuzzPosition(size); | 369 int scale = SkiaScalarToHarfBuzzPosition(size); |
364 hb_font_set_scale(font, scale, scale); | 370 hb_font_set_scale(font, scale, scale); |
365 hb_font_make_immutable(font); | 371 hb_font_make_immutable(font); |
366 return font; | 372 return font; |
367 } | 373 } |
368 | 374 |
369 } // namespace blink | 375 } // namespace blink |
OLD | NEW |